Python Online Compiler
Example: Fibonacci Series Program in Python using For loop
C
C++
C#
Java
Python
PHP
main.py
STDIN
Run
# Fibonacci Series Program in Python using For loop print ("Enter the number of terms to generate the Fibonacci series::\n") x, i, t1, t2, nt = int(input()), 1, 1, 4, 0 # x - To store the number of terms # t1 - To store the term 1 # t2 - To store the term 2 # nt - To store the next term print ("Fibonacci Series:: ", end = "") for i in range(x + 1): print (t1, end = ", ") nt = t1 + t2; t1 = t2 t2 = nt print ("\n")
8
Output
Clear
ADVERTISEMENTS