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()
![]() |
Categories: Problem, Projects/Experiments, Python
ahradwani.com, Ali, Computer, doha, Language, Problem, ProjectEuler, Python
Comments (0)
Trackbacks (0)
Leave a comment
Trackback