Last active
July 3, 2018 01:58
-
-
Save phucnguyen81/8262961b028feb31049e6d1f80650353 to your computer and use it in GitHub Desktop.
Fibonacci sequence in ruby
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 fibonacci_upto(max) | |
| i1, i2 = 1, 1 | |
| while i1 <= max | |
| yield i1 | |
| i1, i2 = i2, i1+i2 | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment