Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,35 @@
|
|||
[ 1 & ] is odd ( n --> b )
|
||||
|
||||
[ []
|
||||
[ over join swap
|
||||
dup 1 > while
|
||||
dup odd iff
|
||||
[ 3 * 1 + ]
|
||||
else
|
||||
[ 2 / ]
|
||||
swap again ]
|
||||
drop ] is hailstone ( n --> [ )
|
||||
|
||||
[ stack ] is longest ( --> s )
|
||||
|
||||
[ stack ] is length ( --> s )
|
||||
|
||||
27 hailstone
|
||||
say "The hailstone sequence for 27 has "
|
||||
dup size echo say " elements." cr
|
||||
say "It starts with"
|
||||
dup 4 split drop witheach [ sp echo ]
|
||||
say " and ends with"
|
||||
-4 split nip witheach [ sp echo ]
|
||||
say "." cr cr
|
||||
|
||||
0 longest put 0 length put
|
||||
99999 times
|
||||
[ i^ 1+ hailstone size
|
||||
dup length share > if
|
||||
[ dup length replace
|
||||
i^ 1+ longest replace ]
|
||||
drop ]
|
||||
longest take echo
|
||||
say " has the longest sequence of any number less than 100000."
|
||||
cr say "It is " length take echo say " elements long." cr
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
The hailstone sequence for 27 has 112 elements.
|
||||
It starts with 27 82 41 124 and ends with 8 4 2 1.
|
||||
|
||||
77031 has the longest sequence of any number less than 100000.
|
||||
It is 351 elements long.
|
||||
Loading…
Add table
Add a link
Reference in a new issue