Check a number is part of the Fibonacci series

In this python if else program, we wiil check a given number is part of the Fibonacci series or not.

What is Fibonacci series?
The Fibonacci sequence is a set of integers (the Fibonacci numbers) that starts with a zero, followed by a one, then by another one, and then by a series of steadily increasing numbers.

Steps to solve the program
  1. Take a list of all the numbers in a Fibonacci series from 0-10.
  2. Take a number as input through the user.
  3. Use if-else statement to check whether the given number is a part of the Fibonacci series or not.
  4. Print the output.
				
					# Fibonacci series
fib = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
# Take input through the user
num = int(input("Enter a number: "))
# Check for number in fibonacci series
if num in fib:
# Print output
    print("It is a part of the series")
else:
# Print output
    print("It is not a part of the series")
				
			

Output :

				
					Enter a number: 22
It is not a part of the series
				
			

Related Articles

check given number is odd or even.

check authentication with the given username and password.

Leave a Comment