- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Program to Find the Fibonacci Series without Using Recursion
When it is required to find the Fibonacci series without using recursion technique, the input is taken from the user, and a ‘while’ loop is used to get the numbers in the sequence.
Example
Below is a demonstration for the same −
first_num = int(input("Enter the first number of the fibonacci series... ")) second_num = int(input("Enter the second number of the fibonacci series... ")) num_of_terms = int(input("Enter the number of terms... ")) print(first_num,second_num) print("The numbers in fibonacci series are : ") while(num_of_terms-2): third_num = first_num + second_num first_num=second_num second_num=third_num print(third_num) num_of_terms=num_of_terms-1
Output
Enter the first number of the fibonacci series... 2 Enter the second number of the fibonacci series... 8 Enter the number of terms... 8 2 8 The numbers in fibonacci series are : 10 18 28 46 74 120
Explanation
- The first number and second number inputs are taken from the user.
- The number of terms is also taken from the user.
- The first and the second numbers are printed on the console.
- A while loop begins, and the below takes place −
- The first and second numbers are added and assigned to a third number.
- The second number is assigned to the third number.
- The third number is assigned to the second number.
- The third number is printed on the console.
- The number of terms is decremented by 1.
- Related Articles
- Python Program to Find the Fibonacci Series Using Recursion
- Fibonacci series program in Java without using recursion.
- Fibonacci series program in Java using recursion.
- Python Program to Display Fibonacci Sequence Using Recursion
- C++ Program to Find Fibonacci Numbers using Recursion
- Python Program to Find the Length of the Linked List without using Recursion
- Python Program to Flatten a List without using Recursion
- Python Program to Reverse a String without using Recursion
- Python Program to find the factorial of a number without recursion
- How to get the nth value of a Fibonacci series using recursion in C#?
- Find fibonacci series upto n using lambda in Python
- Program to find Fibonacci series results up to nth term in Python
- Python Program to Implement Binary Search without Recursion
- Python Program to Find the Sum of Digits in a Number without Recursion
- Python Program to Search for an Element in the Linked List without using Recursion

Advertisements