We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

# Project Euler #25: N-digit Fibonacci number

# Project Euler #25: N-digit Fibonacci number

+ 0 comments For those whose test case 3 is failing despite using the formula, "Wrong Answer" not Timeout, increase precision from float to double.

+ 1 comment from math import log10 as log from math import sqrt def num_of_digits(n): if n == 1: return 1 a = log((1 + sqrt(5))/2) b = ((log(5)) / 2) return(int((n+b-1)/a) + 1) # print(num_of_digits(5)) T = int(input()) for a0 in range(T): N = int(input()) print(num_of_digits(N))

+ 0 comments # This Will Help You

from math import log10, ceil, sqrt phi = (1+sqrt(5))/2 #phi is the golden ratio t = int(input()) for a0 in range(t): d = int(input()) term = ceil((log10(5)/2+d-1)/ log10(phi)) print(term)

+ 0 comments here is a true O(1) solution. No dp, no loops nothing, Just reverse engineering.

; Takes the length of fib return the (index of fib) + 1 (defn fib-len-rev [l] (let [phi (-> (Math/sqrt 5) (+ 1) (/ 2))] (-> (+ (dec l) (* 1/2 (Math/log10 5))) (/ (Math/log10 phi)) (Math/ceil) (int))))

+ 0 comments Hey Folks,

`Do you know if there was any change in the rules of Euler competition ? I am not able to view & download the testcases. I was able to View & Download the test Cases by using hackos before. Please let me know.`

Thanks, Vamshi.

Load more conversations

Sort 76 Discussions, By:

Please Login in order to post a comment