(* Generalized Cantor Sets https://twitter.com/wtgowers/status/1170692765342216192 The Cantor set is the set of all real numbers between 0 and 1 that have just 0s and 1s in their ternary expansion (i.e., no 2s). It is what you get if you continue this process of "removing the middle third" to infinity. We can generalize this to think of an integer Cantor set to consist of all integers that have just 0s and 1s in their base-3 representation. This program uses the same one-pass approach I implemented in , with a twist: no if statements, only boolean expressions. *) function main(n : integer): boolean (n < 2) or ((2 < n) and main(n / 3) and main(MOD(n, 3))) (* from the Klein library *) function MOD(m : integer, n : integer): integer m - m/n * n