class Fib

Public Instance Methods

fib_loop(x) click to toggle source
# File typeprof-0.15.2/smoke/fib.rb, line 2
def fib_loop(x)
  a, b = 0, 1
  while x > 0
    a, b = b, a+b
    x -= 1
  end
  a
end
fib_rec(x) click to toggle source
# File typeprof-0.15.2/smoke/fib.rb, line 11
def fib_rec(x)
  if x <= 1
    x
  else
    fib_rec(x-1) + fib_rec(x-2)
  end
end