The Fibonacci sequence is the series of number: 0,,1,1,2,3,5,….. The next number is found by adding up the tow numbers before it.
- The 2 is found by adding the two numbers before it (1+1)
- The 3 is found by adding the two numbers before it (1+2)
n=int(input("Enter number: ")) def fib(n): a=0 b=1 for i in range(n): if i<=1: n=i else: n=a+b a=b b=n print(n) fib(n)
Enter number 5