Fibonacci Series Using Python For Loop In this article, we are going to print the Fibonacci series Using Python For loop. This term of the series is the sum of two predecessor terms of the series. That's why it goes like, 0, 1, 1, 2, 3, 5, 8, 13, 21, and so on. If you are looking for a Python Tutorial Series then it's here def number(n): a = 0 b = 1 sum = 0 for count in range(1,n+1): print(sum, end=' ') count +=1 a = b b = sum sum = a+b print() number(10) The output of the code is: 0 1 1 2 3 5 8 13 21 34
Comments
Post a Comment