Ruby sample code

tbpgr
5,624 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
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