Simple program to execute sum of fibonacci series in python using while loop. In this program, we can execute the python program for beginners to understand concepts like while loop and its execution procedures.
Fibonacci Series Definition
The Fibonacci sequence is a set of numbers in which each successive number is the sum of the two preceding numbers. The series begins at 0 and 1 and continues indefinitely: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, and so on.
For Loop in Python
In Python, a for loop is a control flow statement that is used to execute a set of statements repeatedly as long as the condition is met. An iterative statement is another name for this type of statement. A for loop is thus an iterative statement.
Sum of Fibonacci Series in Python Using While Loop
no = int(input("Enter the fibonacci series")) a = 0 b = 1 Sum = 0 for Num in range(0, no): print(a, end = ' ') Sum = Sum + a Next = a + b a = b b = Next print("\n Sum of the fibonacci series is %d" %Sum)
Enter the fibonacci series 3
0 1 1
Sum of the fibonacci series is 2