Happy numbers
Output:
Here's another approach that uses a different set of tricks including lazy lists, gather/take, repeat-until, and the cross metaoperator X.
Output is the same as above.
Here is a version using a subset and an anonymous recursion (we cheat a little bit by using the knowledge that 7 is the second happy number):
Again, output is the same as above. It is not clear whether this version returns in finite time for any integer, though.
There's more than one way to do it...
Last updated