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.
importsyssys.set_int_max_str_digits(6000)li=[1,1]answers=[0,1,]x=2max_len=1# I simultaneously calculate the fibonacci numbers and set an answers list corresponding to the nth term which has digits >= that indice of the listwhilemax_len<5000:x+=1new_number=li[-2]+li[-1]length=len(str(new_number))li.append(new_number)iflength>max_len:answers+=[x]*(length-max_len)max_len=lengthfor_inrange(int(input())):n=int(input())print(answers[n])
Cookie support is required to access HackerRank
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 →