Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
|
|
@ -0,0 +1,27 @@
|
|||
fibonacci = function(val)
|
||||
if val < 1 then return []
|
||||
fib = []
|
||||
a = 1; b = 2
|
||||
while a <= val
|
||||
fib.insert(0, a)
|
||||
next = a + b
|
||||
a = b
|
||||
b = next
|
||||
end while
|
||||
return fib
|
||||
end function
|
||||
|
||||
zeckendorf = function(val)
|
||||
seq = fibonacci(val)
|
||||
s = ""
|
||||
for i in seq
|
||||
onOff = val >= i and (s == "" or s[-1] == "0")
|
||||
s += str(onOff)
|
||||
val -= (i*onOff)
|
||||
end for
|
||||
return s
|
||||
end function
|
||||
|
||||
for i in range(1, 20)
|
||||
print [i, zeckendorf(i)]
|
||||
end for
|
||||
Loading…
Add table
Add a link
Reference in a new issue