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.
100%
divide will calculate the reccurance , by long division method by dividing 100* > n
# Enter your code here. Read input from STDIN. Print output to STDOUTsmall_frac=[]defdivide(n):nume={1:10,2:100,3:1000,4:10000,5:100000}d=nume[len(str(n))]divq,rep={},'0'*(len(str(n))-1)l=len(rep)whileTrue:d1=d//nrep=rep+str(d1)d1=d-n*d1d1=d1*10#print(d1, l)ifd1indivq:return(len(rep[divq[d1]:-1]))elifd%n==0:return(0)divq[d1]=ld,l=d1,l+1defdec_frac():lastval=0foriinrange(2,10001):val=divide(i)ifval>lastval:small_frac.append(i)lastval=valdec_frac()#print(small_frac)defsearch(n,l,r,a):ifl==r:ifn<=a[l]:return(a[l-1])return(a[l])m=(l+r)//2ifn<=a[m]:return(search(n,l,m,a))else:return(search(n,m+1,r,a))fora0inrange(int(input())):print(search(int(input()),0,len(small_frac)-1,small_frac))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #26: Reciprocal cycles
You are viewing a single comment's thread. Return to all comments →
100% divide will calculate the reccurance , by long division method by dividing 100* > n