Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Happy-numbers/8th/happy-numbers.8th
Normal file
29
Task/Happy-numbers/8th/happy-numbers.8th
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
: 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue