You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
def fib(n)
|
|
if n <= 0 then 0
|
|
elsif n == 1 then 1
|
|
else fib(n-1) + fib(n-2)
|
|
end
|
|
end
|
|
|
|
puts fib(30)
|
|
|
|
# time of fib(30)
|
|
# real 0m0.166s
|
|
# user 0m0.148s
|
|
# sys 0m0.015s
|