Created
September 27, 2012 03:45
-
-
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
This file contains hidden or 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
| 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