Last active
January 22, 2017 03:33
-
-
Save ta1kt0me/5b58f8f2dcab339c7f36c506930fa42d to your computer and use it in GitHub Desktop.
fib 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 fib | |
| a, b = 0, 1 | |
| Proc.new() { | |
| a, b, c = b, b + a, a | |
| c | |
| } | |
| end | |
| f = fib | |
| 10.times { | |
| p f.call | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment