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 #64: Odd period square roots

# Project Euler #64: Odd period square roots

+ 0 comments Two test caser are running other showing time problem can anyone fix it

import math def getPeriod(x): root=int(math.sqrt(x)) if(root*root==x): return 0 a=root num=0 den=1 per=0 while(a!=2*root): num=den*a-num den=(x-num**2)/den a=(root+num)/den per+=1 return per last=int(input()) numOdd=0 for i in range(2,last): per=getPeriod(i) if(per%2==1): numOdd+=1 print(math.ceil(numOdd)+1)

+ 0 comments You can find my java solution here

+ 0 comments What helped me: Look at the graphic under "The process can be summarised as follows:" and try to create a simple formula how to calculate the new unknown integer in the 2nd fraction from the input and the integers 1st fraction.

+ 1 comment Curious to know if there is a mathematical proof that is guaranteed to be the first repeating occurrence, instead of or .

+ 0 comments seems that kotlin is not supported yet :(

Load more conversations

Sort 9 Discussions, By:

Please Login in order to post a comment