Fusc sequence
editable example
Click the pencil to open this in an editor, change it, and run it in your browser. The same solution is posted on Rosetta Code.
ghul
use IO.Std.write_line
use Collections.LIST
use Ghul.Pipes
let limit = 1000000
let fusc = LIST[int]([0, 1])
while fusc.count <= limit do
let n = fusc.count
if n % 2 == 0 then
fusc.add(fusc[n / 2])
else
fusc.add(fusc[n / 2] + fusc[n / 2 + 1])
fi
od
write_line(fusc |> take(61) |> join(", "))
let longest mut = 0
for index in 0::limit do
let digits = fusc[index].to_string().length
if digits > longest then
longest = digits
write_line("fusc[{index:N0}] = {fusc[index]:N0}")
fi
od