Module: Fibc

Defined in:
lib/fibc.rb,
lib/fibc/version.rb,
ext/fibc/fibc.c

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.fib(r_num) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'ext/fibc/fibc.c', line 12

VALUE rb_fibc(VALUE self, VALUE r_num) {
  Check_Type(r_num, T_FIXNUM);

  long num = FIX2LONG(r_num);

  long res = fibc(num);

  return LONG2FIX(res);
}

.fib_pure(n) ⇒ Object



7
8
9
10
# File 'lib/fibc.rb', line 7

def self.fib_pure(n)
  return n if n == 0 || n == 1
  fib_pure(n-1) + fib_pure(n-2)
end