Skip to content
Home » Python Programs » Fibonacci Series in Python Using Range

Fibonacci Series in Python Using Range

Simple fibonacci series in python using range. In this program, we can execute the Fibonacci series in python using a given range by the users in python.

Fibonacci Series Definition

The Fibonacci sequence is a set of numbers in which each subsequent number is equal to the sum of the two numbers before it. The sequence starts with 0 and 1 and goes on indefinitely: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, and so on. Xn+2= Xn+1 + Xn is a mathematical equation that can be used to define the Fibonacci sequence.

Function Definition

A function is a piece of code that only executes when called. If a return statement is given, Python functions return a value. After a function has been declared, it can be invoked from anywhere.

For Loop Definition in Python

When you have a block of code that you want to repeat a certain number of times, you use a for a loop. The for the statement in Python iterates through the members of a sequence, executing the block each time.

Fibonacci Series in Python Using Range

import math
def isfunc(x):
	s = int(math.sqrt(x))
	return s*s == x
def fib(n):
	return isfunc(5*n*n + 4) or isfunc(5*n*n - 4)
for i in range(5,13):
	if (fib(i) == True):
		print (i," Fibonacci Number")
		print (i,"Not Fibonacci Number ")


5  Fibonacci Number

6 Not Fibonacci Number 

7 Not Fibonacci Number 

8  Fibonacci Number

9 Not Fibonacci Number 

10 Not Fibonacci Number 

11 Not Fibonacci Number 

12 Not Fibonacci Number 

13  Fibonacci Number