Skip to content

Instantly share code, notes, and snippets.

@scarow
Last active December 19, 2015 05:29
Show Gist options
  • Save scarow/5904586 to your computer and use it in GitHub Desktop.
Save scarow/5904586 to your computer and use it in GitHub Desktop.
Fibonacci Number Exercise
def is_fibonacci?(i)
fib_arr = [0, 1]
while fib_arr[-1] <= i do
next_num = (fib_arr[-1] + fib_arr[-2])
fib_arr << next_num
end
if fib_arr.include?(i)
true
else
false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment