Last active
August 29, 2015 14:06
-
-
Save dd1994/75db7ce38aa23a3e1c5a to your computer and use it in GitHub Desktop.
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(n) | |
| raise "bad argument" if n < 1 or n.is_a? Float | |
| return 1 if n == 1 or n == 2 | |
| fibonacci(n-1) + fibonacci(n-2) | |
| end | |
| n = Integer(ARGV[0]) | |
| 1.upto(n) {|x| print fibonacci(x).to_s + " "} | |
| print "\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment