Ruby sample code

tbpgr
2,073 views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Fibonacci

Fibonacci
1
2
3
4
5
def fibonacci(i)
return i if (0..1).include?(i)
fibonacci(i - 1) + fibonacci(i - 2)
end
print (1..20).map{|i|fibonacci(i)}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content