RosettaCodeData/Task/Fusc-sequence/Quackery/fusc-sequence.quackery

39 lines
767 B
Plaintext

[ 1 & ] is odd ( n --> b )
[ 0 swap
[ dip 1+
10 / dup
0 = until ]
drop ] is digits ( n --> n )
[ dup dup size
dup odd iff
[ dup 1 - 2 /
dip
[ 1 + 2 / peek
over ]
peek + ]
else
[ 2 / peek ]
join ] is nextfusc ( [ --> [ )
say "First 61 terms." cr
' [ 0 1 ]
59 times nextfusc
witheach [ echo sp ]
cr cr
say "Terms where the digit count increases." cr
say "fusc(0) = 0" cr
1 ' [ 0 1 ]
[ nextfusc
dup -1 peek digits
rot 2dup > iff
[ drop swap
say "fusc("
dup -1 peek echo
say ") = "
dup size 1 - echo cr ]
else [ nip swap ]
dup size 1000000 = until ]
2drop