Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
14
Task/Hailstone-sequence/Lingo/hailstone-sequence-1.lingo
Normal file
14
Task/Hailstone-sequence/Lingo/hailstone-sequence-1.lingo
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
on hailstone (n, sequenceList)
|
||||
len = 1
|
||||
repeat while n<>1
|
||||
if listP(sequenceList) then sequenceList.add(n)
|
||||
if n mod 2 = 0 then
|
||||
n = n / 2
|
||||
else
|
||||
n = 3 * n + 1
|
||||
end if
|
||||
len = len + 1
|
||||
end repeat
|
||||
if listP(sequenceList) then sequenceList.add(n)
|
||||
return len
|
||||
end
|
||||
16
Task/Hailstone-sequence/Lingo/hailstone-sequence-2.lingo
Normal file
16
Task/Hailstone-sequence/Lingo/hailstone-sequence-2.lingo
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
sequenceList = []
|
||||
hailstone(27, sequenceList)
|
||||
put sequenceList
|
||||
-- [27, 82, 41, 124, ... , 8, 4, 2, 1]
|
||||
|
||||
n = 0
|
||||
maxLen = 0
|
||||
repeat with i = 1 to 99999
|
||||
len = hailstone(i)
|
||||
if len>maxLen then
|
||||
n = i
|
||||
maxLen = len
|
||||
end if
|
||||
end repeat
|
||||
put n, maxLen
|
||||
-- 77031 351
|
||||
Loading…
Add table
Add a link
Reference in a new issue