Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- fibo_1 = 1
- fibo_2 = 1
- index_1000digit = 0
- index_10000digit = 0
- index = 3
- while(1):
- fibo_n = fibo_1 + fibo_2
- power10 = int(math.log10(fibo_n))
- if(power10 == 999 and index_1000digit == 0):
- index_1000digit = index
- elif(power10 == 9999 and index_10000digit == 0):
- index_10000digit = index
- break;
- fibo_1 = fibo_2
- fibo_2 = fibo_n
- index = index + 1
- print("Index for 1st Fibonacci number with 1000 digits is:", index_1000digit)
- print("Index for 1st Fibonacci number with 10000 digits is:", index_10000digit)
- # OUTPUT:
- # Index for 1st Fibonacci number with 1000 digits is: 4782
- # Index for 1st Fibonacci number with 10000 digits is: 47847
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement