Created
December 27, 2012 09:27
-
-
Save 8bit-pixies/4386876 to your computer and use it in GitHub Desktop.
challenge 74
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#chall 74 in ruby | |
#zeckendorf representation | |
def fib_seq(m) | |
#get array of fibonacci seq up to a certain number | |
seq = [1,1] | |
until seq[-1] > m do | |
seq.push(seq[-1]+seq[-2]) | |
end | |
remainder = m | |
for x in seq.reverse | |
if x <= remainder.to_i | |
remainder = remainder - x | |
p x | |
end | |
end | |
end | |
fib_seq(3**15) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment