Skip to content

Instantly share code, notes, and snippets.

@scottchiang
Created September 27, 2012 03:45
Show Gist options
  • Select an option

  • Save scottchiang/3792051 to your computer and use it in GitHub Desktop.

Select an option

Save scottchiang/3792051 to your computer and use it in GitHub Desktop.
A method to determine if a given number is a part of the Fibonacci Sequence
def is_fibonacci?(i)
ary=[]
(1..100).inject([0]) {|ary, x| x>1? ary<< ary[-1]+ary[-2] : ary << 1}
ary.include?(i)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment