RosettaCodeData/Task/Happy-numbers/Forth/happy-numbers-3.fth
2017-09-25 22:28:19 +02:00

5 lines
177 B
Forth

: happy-number ( n -- n') \ produce the nth happy number
>r 0 BEGIN r@ WHILE
BEGIN 1+ dup happy? UNTIL r> 1- >r
REPEAT r> drop ;
1000000 happy-number . \ 7105849