Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
27
Task/Fusc-sequence/Julia/fusc-sequence.julia
Normal file
27
Task/Fusc-sequence/Julia/fusc-sequence.julia
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using Memoize, Formatting
|
||||
|
||||
@memoize function sternbrocot(n)
|
||||
if n < 2
|
||||
return n
|
||||
elseif iseven(n)
|
||||
return sternbrocot(div(n, 2))
|
||||
else
|
||||
m = div(n - 1, 2)
|
||||
return sternbrocot(m) + sternbrocot(m + 1)
|
||||
end
|
||||
end
|
||||
|
||||
function fusclengths(N=100000000)
|
||||
println("sequence number : fusc value")
|
||||
maxlen = 0
|
||||
for i in 0:N
|
||||
x = sternbrocot(i)
|
||||
if (len = length(string(x))) > maxlen
|
||||
println(lpad(format(i, commas=true), 15), " : ", format(x, commas=true))
|
||||
maxlen = len
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
println("The first 61 fusc numbers are: ", [sternbrocot(x) for x in 0:60])
|
||||
fusclengths()
|
||||
Loading…
Add table
Add a link
Reference in a new issue