2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -0,0 +1,31 @@
hail: func [
"Returns the hailstone sequence for n"
n [integer!]
/local seq
] [
seq: copy reduce [n]
while [n <> 1] [
append seq n: either n % 2 == 0 [n / 2] [3 * n + 1]
]
seq
]
hs27: hail 27
print [
"the hail sequence of 27 has length" length? hs27
"and has the form " copy/part hs27 3 "..."
back back back tail hs27
]
maxN: maxLen: 0
repeat n 99999 [
if (len: length? hail n) > maxLen [
maxN: n
maxLen: len
]
]
print [
"the number less than 100000 with the longest hail sequence is"
maxN "with length" maxLen
]