Sha256: 2876364fc3ba969175db496117fbf0e88fb077bcdbd20f3eb178abafd70f322d

Contents?: true

Size: 362 Bytes

Versions: 3

Compression:

Stored size: 362 Bytes

Contents

class Fib
  def fib_loop(x)
    a, b = 0, 1
    while x > 0
      a, b = b, a+b
      x -= 1
    end
    a
  end

  def fib_rec(x)
    if x <= 1
      x
    else
      fib_rec(x-1) + fib_rec(x-2)
    end
  end
end

Fib.new.fib_loop(42)
Fib.new.fib_rec(42)

__END__
# Classes
class Fib
  def fib_loop: (Integer) -> Integer
  def fib_rec: (Integer) -> Integer
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
typeprof-0.9.2 smoke/fib.rb
typeprof-0.9.1 smoke/fib.rb
typeprof-0.9.0 smoke/fib.rb