def test_fib_iter(self): self.assertEqual(fib_iter(10), 55) self.assertEqual(fib_iter(30), 832040)
def test_fib_iter(self): self.assertEqual(fib_iter(10), 55) self.assertEqual(fib_iter(30), 832040)
for _ in range(n-1): sum=fib1+fib2 fib1=fib2 fib2=sum return sum def fibonacci2(n): a, b = 0, 1 for _ in range(n): a, b = b, a + b return a n=20 print(fib_recursive(n)) n=100 print(fib_list(n)) n=100 print(fib_iter(n)) n=1000 print(finbonacci_iter(n)) print(fibonacci2(n)) #print(fibo_num_digits(n))