29 lines
462 B
Text
29 lines
462 B
Text
: until! "not while!" eval i;
|
|
|
|
with: w
|
|
with: n
|
|
|
|
: sumsqd \ n -- n
|
|
0 swap repeat
|
|
0; 10 /mod -rot sqr + swap
|
|
again ;
|
|
|
|
: cycle \ n xt -- n
|
|
>r
|
|
dup r@ exec \ -- tortoise, hare
|
|
repeat
|
|
swap r@ exec
|
|
swap r@ exec r@ exec
|
|
2dup = until!
|
|
rdrop drop ;
|
|
|
|
: happy? ' sumsqd cycle 1 = ;
|
|
|
|
: .happy \ n --
|
|
1 repeat
|
|
dup happy? if dup . space swap 1- swap then 1+
|
|
over 0 > while!
|
|
2drop cr ;
|
|
|
|
;with
|
|
;with
|