You are viewing a single comment's thread. Return to all comments →
Using binary search and printing the lower bound
from math import log, ceil def numberOfDigits(n): if n==1: return 1 ans = (n * log(1.6180339887498948, 10)) - ((log(5, 10)) / 2) return ceil(ans) testcases = input() while testcases: low, high = 0, 25000 n = input() while low < high: mid = (low+high)/2 mid_n = numberOfDigits(mid) if mid_n >= n: high = mid else: low = mid+1 print((low+high)/2) testcases -= 1
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #25: N-digit Fibonacci number
You are viewing a single comment's thread. Return to all comments →
Using binary search and printing the lower bound