ahmed
· @abo-elleef
·
almost 3 years
what if n is negative ?
Ahmed Khaled · @nemoload · about 3 years
Calculating the n-th number in Fibonacci sequence with dynamic programming.
def fib_with_memoizing(n, mem)return n if [0, 1].include? nreturn mem[n] if mem[n]mem[n] = fib(n - 2, mem) + fib(n - 1, mem)end
what if n is negative ?