~statianzo/sevenlangs

sevenlangs/io/fib.rb -rw-r--r-- 179 bytes
2fcd4511Jason Staten day one logic style 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
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