Sha256: f3d3efbf6b50e2c6afaa530b01c5e2ee165bbf90409d7713691901b3e0d42b35

Contents?: true

Size: 364 Bytes

Versions: 19

Compression:

Stored size: 364 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

19 entries across 19 versions & 1 rubygems

Version Path
typeprof-0.8.0 smoke/fib.rb
typeprof-0.7.0 smoke/fib.rb
typeprof-0.6.1 smoke/fib.rb
typeprof-0.6.0 smoke/fib.rb
typeprof-0.5.4 smoke/fib.rb
typeprof-0.5.3 smoke/fib.rb
typeprof-0.5.2 smoke/fib.rb
typeprof-0.5.1 smoke/fib.rb
typeprof-0.5.0 smoke/fib.rb
typeprof-0.4.2 smoke/fib.rb
typeprof-0.4.1 smoke/fib.rb
typeprof-0.4.0 smoke/fib.rb
typeprof-0.3.0 smoke/fib.rb
typeprof-0.2.0 smoke/fib.rb
typeprof-0.1.4 smoke/fib.rb
typeprof-0.1.3 smoke/fib.rb
typeprof-0.1.2 smoke/fib.rb
typeprof-0.1.1 smoke/fib.rb
typeprof-0.1.0 smoke/fib.rb