Advertisement
Programmin-in-Python

Finding the Nth Fibonacci number in the series using Tuple

Oct 10th, 2021
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.19 KB | None | 0 0
  1. n = int(input("Enter the value of n : "))
  2.  
  3. f, s = 1, 1
  4. T1 = (f, s)
  5.  
  6. for i in range(n-1):
  7.     t = f + s
  8.     T1 += (t,)
  9.     f, s = s, t
  10.  
  11. print(f"{n}th term in the fibonacci series is : {T1[n-1]}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement