def fib(n):
if n <= 1:
return n
return fib(n-1) + fib(n-2)
def fib_no_recusive(n):
if n <= 1:
return n
i, j, k, r = 0, 1, 2, 0
while k <= n:
r = i + j
k += 1
i, j = j, r
return r
def frog_jump(n):
if n <= 2:
return n
i, j, k, r = 1, 2, 3, 0
while k <= n:
r = i + j
k += 1
i, j = j, r
return r
if __name__ == "__main__":
print(fib(3))
print(fib(10))
print(fib_no_recusive(3))
print(fib_no_recusive(10))
print(fib_no_recusive(100))
print(frog_jump(2))
print(frog_jump(3))
print(frog_jump(10))