Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/Hailstone-sequence/Frink/hailstone-sequence.frink
Normal file
30
Task/Hailstone-sequence/Frink/hailstone-sequence.frink
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
hailstone[n] :=
|
||||
{
|
||||
results = new array
|
||||
|
||||
while n != 1
|
||||
{
|
||||
results.push[n]
|
||||
if n mod 2 == 0 // n is even?
|
||||
n = n / 2
|
||||
else
|
||||
n = (3n + 1)
|
||||
}
|
||||
|
||||
results.push[1]
|
||||
return results
|
||||
}
|
||||
|
||||
longestLen = 0
|
||||
longestN = 0
|
||||
for n = 1 to 100000
|
||||
{
|
||||
seq = hailstone[n]
|
||||
if length[seq] > longestLen
|
||||
{
|
||||
longestLen = length[seq]
|
||||
longestN = n
|
||||
}
|
||||
}
|
||||
|
||||
println["$longestN has length $longestLen"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue