Home > Problem, Projects/Experiments, Python > Python: 1000-Digit Fibonacci

Python: 1000-Digit Fibonacci



Python: 1000-Digit Fibonacci
Problem No.25, ProjectEuler

Another easy fast 5-minites task on projecteuler that Playing around Fibonacci Numbers, the task is to find the first Fibonacci index to contain 1000 digits.

So we will write a function to get the fibonacci numbers and each time we will check if it’s digits reach 1000, if not we will go for generating the next number.



The Code:



#1000-digit Fibonacci number
# problem no 25
# Solved.

def get_fibonacci():

x=1

fibo=[1,1]

while len(str(fibo[x])) != 1000:

fibo.append(fibo[-2]+fibo[-1])

x +=1

print(‘The index of the first term in the Fibonacci sequence to contain 1000 digits is ‘,x+1)

# Call the function
get_fibonacci()






Follow me on Twitter..



  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s