def run(): sum = 0 for i in range(10001): if eu.is_square(i): continue cf = eu.sqrt_continued_fraction(i) if len(cf) % 2 == 0: sum += 1 return sum
def test(): sum = 0 for i in range(14): if eu.is_square(i): continue cf = sqrt_continued_fraction(i) if len(cf) % 2 == 0: sum += 1 assert sum == 4, 'there are only 4 matches for x <=13'
def max_x(max_d): ''' for all d <= max_d, this finds the d for which the solution to Pell (x,y) minimizing x is maximal in x. ''' max = 0 rslt = None for d in range(2,max_d + 1): if eu.is_square(d): continue x,y = pell_min_x(d) if x > max: max = x rslt = d return rslt