2014-04-28 15:47:12 +02:00
|
|
|
def fibonaccit(n)
|
2015-11-06 13:24:57 +01:00
|
|
|
a = 0
|
2014-04-28 15:47:12 +02:00
|
|
|
b = 1
|
|
|
|
(n-1).times do
|
|
|
|
tmp = a
|
|
|
|
a = b
|
|
|
|
b = tmp + b
|
|
|
|
end
|
2015-11-06 13:24:57 +01:00
|
|
|
b
|
2014-04-28 15:47:12 +02:00
|
|
|
end
|
|
|
|
|
2015-11-06 13:24:57 +01:00
|
|
|
#1000000.times {fibonaccit( 30 )}
|
2015-11-08 14:15:55 +01:00
|
|
|
#10.times {|i| puts fibonaccit(i+90).class}
|
|
|
|
puts fibonaccit 90
|