EVEN AND ODD PERIODS IN CONTINUED FRACTIONS OF SQUARE ROOTS P.J. Rippon Department of Pure Mathematics, The Open University, Walton Hall, Milton Keynes MK7 6AA, United Kingdom H. Taylor 32 Pont Adam, Ruabon, Wrexham, LL14 6ED, United Kingdom (Submitted October 2001–Final Revision April 2002) 1. INTRODUCTION Throughout √ this paper N is a positive integer which is not a perfect square. The continued fraction for N has the periodic form √ N = [a0 , a1 , a2 , . . . , al ], (1.1) where a1 , a2 , . . . , al−1 is a palindrome (al−1 = a1 , and so on) and al = 2a0 ; see, for example, [2, page 104]. The period l = l(N ) is assumed to be of minimal length. This paper gives several new results concerning the following intriguing question; see [2, page 111]. Question: How can we distinguish between those integers N for which l(N ) is even and those for which l(N ) is odd? 2. RESULTS A well-known characterisation of the integers for which l(N ) is odd is related to the Diophantine equations x2 − N y 2 = ±1. The √solutions of these equations are found amongst the convergents of the continued fraction for N , which are of the form [a0 , a1 , . . . , an ] = An , n = 0, 1, 2, . . . , Bn (2.1) where An Bn An−1 Bn−1 = a0 1 1 0 a1 1 1 0 ... an 1 1 0 see [1, pages 45 and 75-76] or [2, pages 84 and 110]. Theorem A: Let l = l(N ). Then (a) the positive integer solutions of x2 − N y 2 = 1, Pell’s equation, are x = Akl−1 , y = Bkl−1 , for k = 1, 2, 3, . . . , x = Akl−1 , y = Bkl−1 , for k = 2, 4, 6, . . . , when l is even, and when l is odd; 170 ; (2.2) EVEN AND ODD PERIODS IN CONTINUED FRACTIONS OF SQUARE ROOTS (b) the positive integer solutions of x2 − N y 2 = −1 are x = Akl−1 , y = Bkl−1 , for k = 1, 3, 5, . . . , when l is odd, and there are no solutions when l is even. Theorem A yields the following characterisation. Theorem B: The period l(N ) is odd if and only if the equation x2 − N y 2 = −1 has integer solutions. This characterisation leads to two simpler necessary conditions for l(N ) to be odd. Theorem C: If l(N ) is odd, then the following two (equivalent) conditions hold: (a) N = u2 + v 2 , where (u, v) = 1; (b) N has no prime factors of the form 4k + 3 and is not divisible by 4. Theorem C is given in [2, pages 111 and 139], where it is also pointed out that the conditions (a) and (b) are not sufficient for l(N ) to be odd. For example, 34 = 32 + 52 , but l(34) = 4. More generally, if p ≥ 3 is prime, then N = p2 + ( 12 (p2 + 1))2 is a sum of coprime squares, but l(N ) = 4. Indeed, N = k 2 − 2, where k = 12 (p2 + 3), and it follows that √ N = [k − 1, 1, k − 2, 1, 2k − 2]; see [3, page 110]. In this paper, we establish further necessary and sufficient conditions for l(N ) to be odd (or even). None of these conditions is simple to verify for a general non-square integer N , but they may shed some light on the delicate question of the difference between odd and even l(N ). In particular, we derive some new families of integers N for which l(N ) is odd. To state our results, we need more notation relating to (1.1). Let pn [a1 , a2 , . . . , an ] = , 1 ≤ n ≤ l(N ) − 1, qn be the convergents of [a1 , a2 , . . . , al−1 ]; that pn pn−1 a1 = qn qn−1 1 is, 1 a2 0 1 1 0 ... an 1 1 0 , (2.3) for 1 ≤ n ≤ l(N ) − 1. (2.4) with the convention that p0 = 1 and q0 = 0. It follows that pn qn−1 − qn pn−1 = (−1)n , Also, it is convenient to define A B B C = pl−1 ql−1 pl−2 ql−2 , (2.5) with the convention that if the palindrome is empty, then this matrix is the identity. The symmetry in this matrix arises from the fact that a1 , a2 , . . . , al−1 form a palindrome. The quantities A, B and C play a key role in what follows. First we give two characterisations of those N for which l(N ) is odd, both closely related to Theorem C, part (a). Theorem 1: The period l(N ) is odd if and only if N = u2 + v 2 , where (u, v) = 1, and A is odd. Theorem 2: The period l(N ) is odd if and only if N = u2 + v 2 , where 2xyu − (x2 − y 2 )v = ±1, for some x, y ∈ Z. (2.6) 171 EVEN AND ODD PERIODS IN CONTINUED FRACTIONS OF SQUARE ROOTS Next we characterise those N for which l(N ) is even, in terms of factorisations of N . Theorem 3: The period l(N ) is even if and only if N = rs, where r and s are positive integers such that one of the following conditions holds: (a) x2 r − y 2 s = ±2, for some odd x, y; (b) r, s 6= 1 and x2 r − y 2 s = ±1, for some x, y ∈ Z. Theorem 3 leads to the following sufficient condition for l(N ) to be even. Corollary 1: Let N = rs, where r and s are positive integers such that: r, s 6= 2 and x2 r − y 2 s = ±2, for some x, y ∈ Z. Then l(N ) is even. The example N = 34, with r = 1, s = 34, x = 6 and y = 1, shows that Corollary 1 is not vacuous. Note that r, s 6= 2 cannot be dropped from the condition in Corollary 1; for example, √ 74 = [8, 1, 1, 1, 1, 16] satisfies 432 × 2 − 102 × 37 = −2. Also,√condition (a) in Theorem 3 cannot be replaced by the condition in Corollary 1; for example, 8 = [2, 1, 4] satisfies neither Theorem 3, condition (b) nor the condition in Corollary 1. It is easy to deduce from Theorem 3 that if N = pt , where p is a prime of the form 4k + 1 and t is odd, then l(N ) is odd; see [3, page 108] for a direct proof of this result. The example 205 = 5 × √ 41 shows that N can be a product of different primes of the form 4k + 1, while l(N ) is even; 205 = [14, 3, 6, 1, 4, 1, 6, 3, 28]. Theorem 3 can be used to obtain other cases for which l(N ) is odd. Corollary 2: For positive integers N of the following forms, l(N ) is odd: (a) N = 2pt , where p is a prime of the form 8k + 5 and t ≥ 1; (b) N = 2pt11 pt22 , where p1 , p2 are primes of the form 8k + 5 and t1 , t2 are odd; (c) N = 2pt11 . . . ptmm , where p1 , . . . , pm are primes of the form 8k + 5 and t1 , . . . , tm are even. Part (a) of Corollary 2 is given in [3, page 108], but parts (b) and (c) appear to be new. It is natural to conjecture that in part (c) we could replace the assumption that all the powers are even by the assumption that all the powers are odd. However, a counter-example is √ 653 066 = 2 × 53 × 61 × 101, for which 653 066 = [808, 8, 1616]. We prove Theorems 1 and 2 in Section 2, and then Theorem 3 and its corollaries in Section 3. In Section 4 we give alternative versions of some of the identities which occur in the proofs of Theorems 2 and 3. 3. PROOFS OF THEOREMS 1 AND 2 To prove Theorem 1, we first note that if l = l(N ), then Al−1 = a0 A + B, Bl−1 = A, by (2.2), (2.3) and (2.5). Now assume that l(N ) is odd. Then N = u2 + v 2 , where (u, v) = 1, 2 by Theorem C, part (a). Also, A2l−1 − N Bl−1 = −1, by Theorem A, part (b). Since A2l−1 is congruent to 0 or 1 (mod 4), we deduce that A = Bl−1 is odd, as required. Next assume that N = u2 + v 2 , where (u, v) = 1, and A is odd. Since parts (a) and (b) 2 of Theorem C are equivalent, N is congruent to 1 or 2 (mod 4). Also, Bl−1 = A2 ≡ 1 (mod 2 4). Thus A2l−1 − N Bl−1 = 1 does not hold, so l(N ) is odd by Theorem A, part (a). To prove Theorem 2, we need a version of the Euler-Muir theorem; see [3, page 98]. Lemma 1: Let a0 , a1 , a2 , . . . , al−1 ∈ N , where a1 , a2 , . . . , al−1 is a palindrome, and put x = [a0 , a1 , a2 , . . . , al−1 , 2a0 ]. 172 EVEN AND ODD PERIODS IN CONTINUED FRACTIONS OF SQUARE ROOTS Also, let A, B and C be defined as in (2.5). Then (a) x = q a20 + 2a0 B+C ; A √ N for some integer N if and only if a0 ≡ 21 BC(−1)l−1 (mod A0 ), where A, if A is odd, 0 A = 1 2 A, if A is even; √ (c) the palindrome a1 , a2 , . . . , al−1 appears in the continued fraction for some N if and only if BC is even. For completeness, we outline a proof. Let α = x + a0 = [2a0 , a1 , a2 , . . . , al−1 ]. The convergents of α are found from the columns of 2a0 1 A B , 1 0 B C (b) x = so, by periodicity and [2, page 90, equation (14)], α= (2a0 A + B)α + (2a0 B + C) . Aα + B On solving this equation√for α, we obtain Lemma 1, part (a). It follows that x = N , where N ∈ N , if and only if a0 belongs to the set 2aB + C S= a∈Q: ∈Z . A By (2.4) and (2.5), AC = B 2 + (−1)l−1 , (3.1) so 21 BC(−1)l−1 ∈ S. Thus a0 ∈ S if and only if 2a0 = BC(−1)l−1 + kA/B, for some k ∈ Z. By (3.1), we have (A, B) = 1, and also A and BC are not both odd. Parts (b) and (c) of Lemma 1 now follow. We prove the ‘only if’ direction of Theorem 2 in the following lemma, using a method of Legendre; see [2, page 120]. √ Lemma 2: Let the continued fraction for N be given by (1.1), and let l(N ) = 2m + 1. Then N = u2 + v 2 , where u= 1 a0 p2m − p2m−1 + pm qm − pm−1 qm−1 , A (3.2) 1 (2a0 pm pm−1 + pm−1 qm + pm qm−1 ) , A (3.3) v= are integers which satisfy 2pm pm−1 u − p2m − p2m−1 v = (−1)m+1 . 173 (3.4) EVEN AND ODD PERIODS IN CONTINUED FRACTIONS OF SQUARE ROOTS Proof: Consider the number β = [am , am−1 , . . . , a1 , 2a0 , a1 , . . . , am ], which is purely periodic with symmetric period, so ββ 0 = −1, where β 0 is the quadratic conjugate of β; see [2, pages 100-104]. Since √ Am β + Am−1 N= , Bm β + Bm−1 we obtain √ √ Bm−1 N − Am−1 (−1)m (Am Am−1 − Bm Bm−1 N ) + N √ β= = , 2 N) (−1)m+1 (A2m − Bm −Bm N + Am on using Am Bm−1 − Bm Am−1 = (−1)m+1 . Thus if u = (−1)m (Am Am−1 − Bm Bm−1 N ) (3.5) 2 v = (−1)m+1 (A2m − Bm N ), (3.6) and then √ √ u+ N u− N 0 β= , β = , v v so ββ 0 = −1 implies that N = u2 + v 2 . Now we express u and v in terms of a0 , pm , pm−1 , qm and qm−1 . By (2.2) and (2.3), Am = a0 pm + qm , Am−1 = a0 pm−1 + qm−1 , Bm = pm , Bm−1 = pm−1 , and, by the proof of Lemma 1, N = a20 + (3.7) 2a0 B + C . A Also 2 2 A = p2m + p2m−1 , B = pm qm + pm−1 qm−1 , C = qm + qm−1 , since, by (2.3) and (2.5), A B B C = pm qm pm−1 qm−1 pm qm pm−1 qm−1 (3.8) . On substituting all these expressions into (3.5) and (3.6), expanding and cancelling with the help of (2.4), we obtain (3.2) and (3.3). The equation (3.4) readily follows. To complete the proof of Theorem 2, note that if N = u2 + v 2 , where 2xyu − (x2 − y 2 )v = ±1, then ((x2 − y 2 )u + 2xyv)2 − (x2 + y 2 )2 N = −1. Thus the equation x2 − N y 2 = −1 has integer solutions, so l(N ) is odd by Theorem B. 174 EVEN AND ODD PERIODS IN CONTINUED FRACTIONS OF SQUARE ROOTS 4. PROOF OF THEOREM 3 We prove the ‘only if’ direction of Theorem 3 in the following lemma. √ Lemma 3: Let the continued fraction for N be given by (1.1), and let l(N ) = 2m + 2. Then (a) the quantities A, B and C in (2.5) are given by A = pm (pm+1 + pm−1 ), B = pm+1 qm + pm qm−1 , C = qm (qm+1 + qm−1 ); (4.1) (b) N = rs, where r= a0 pm + qm a0 (pm+1 + pm−1 ) + qm+1 + qm−1 , s= ; pm+1 + pm−1 pm (4.2) (c) if A is odd, then r and s are integers, pm+1 + pm−1 and pm are both odd, and (pm+1 + pm−1 )2 r − p2m s = 2(−1)m+1 ; (4.3) (d) if A is even, then 2r and 12 s are integers strictly greater than 1, pm+1 + pm−1 is even, and 1 (pm+1 + pm−1 ) 2 2 (2r) − p2m 1 s = (−1)m+1 . 2 (4.4) Proof: The identities in part (a) follow from the equation A B pm+1 pm pm qm = , B C qm+1 qm pm−1 qm−1 which derives from (2.3) and (2.5). Next, by (2.4), B = qm (pm+1 + pm−1 ) + (−1)m = pm (qm+1 + qm−1 ) + (−1)m+1 . (4.5) Also, by (3.1), we have AC = B 2 − 1. Thus, by Lemma 1, (4.1) and (4.5), N= a20 A2 + 2a0 AB + AC A2 = (a0 A + B − (−1)m )(a0 A + B − (−1)m+1 ) A2 = a0 pm + qm pm+1 + pm−1 a0 (pm+1 + pm−1 ) + qm+1 + qm−1 pm = rs, which proves part (b). Now note that (4.3) and (4.4) follow easily from (4.2). To complete the proofs of parts (c) and (d), we obtain new formulas for r and s. Let a0 = − 21 BC + kA0 , where k ∈ Z and A0 is defined as in Lemma 1. By (4.1), (2.4) and (4.5), we have 1 2 1 (pm+1 + pm−1 )(−B + 2(−1)m+1 ) − BCpm + qm = qm 2 2 175 EVEN AND ODD PERIODS IN CONTINUED FRACTIONS OF SQUARE ROOTS and 1 1 − BC(pm+1 + pm−1 ) + qm+1 + qm−1 = (qm+1 + qm−1 )2 pm (−B + 2(−1)m ). 2 2 If k, if A is odd, 1 2 k, if A is even, 0 0 0 then kA = k A = k pm (pm+1 + pm−1 ). Thus 0 k = 1 2 q (−B + 2(−1)m+1 ) + k 0 p2m 2 m (4.6) 1 (qm+1 + qm−1 )2 (−B + 2(−1)m ) + k 0 (pm+1 + pm−1 )2 . 2 (4.7) r= and s= Now assume that A is odd. Then k 0 = k and both pm and pm+1 + pm−1 are odd, by (4.1). If B is even, then −B + 2(−1)m+1 and −B + 2(−1)m are even. If B is odd, then qm (pm+1 + pm−1 ) and pm (qm+1 + qm−1 ) are both even, by (4.5), so qm and qm+1 + qm−1 are both even. In either case, r and s are both integers. This proves part (c). Next assume that A is even. Then k 0 = 12 k and B is odd, by (3.1), so C is even by Lemma 1, part (c). If pm+1 +pm−1 is odd, then both pm and qm are even, by (4.1) and (4.5), and this is impossible by (2.4). Thus pm+1 + pm−1 is even. Similarly, qm+1 + qm−1 is even. Hence 2r and 1 1 1 2 s are integers. If 2r = 1 or 2 s = 1, then (4.4) shows that x = 2 (pm+1 + pm−1 ), y = pm are 2 2 solutions of one of the equations x − N y = ±1. But this is impossible because, by Theorem A, the smallest positive solutions of these equations are x = Al−1 , y = Bl−1 and 1 Al−1 = a0 A + B > A ≥ max{ (pm+1 + pm−1 ), pm }, 2 since B ≥ 1. The proof of Lemma 3 is complete. We use several lemmas to prove the ‘if’ direction of Theorem 3, the first of which is a straightforward consequence of Theorem B. Lemma 4: Let M = a2 N , where a ∈ Z and N is not a perfect square. If l(N ) is even, then l(M ) is even. We also use the following result, which is part of [5, Theorem 1]. Lemma 5: Suppose that N = rs, where r and s are squarefree integers with r, s > 1. If there exist integers x and y such that x2 r − y 2 s = ±1, then l(N ) is even. Finally, we need a coprimeness result about solutions of the equations x2 − N y 2 = ±1, which may be of independent interest. By Theorem A, these solutions are of the form x = Akl−1 , y = Bkl−1 , k = 1, 2, · · · , where l = l(N ). With uk = Akl−1 , vk = Bkl−1 , they can be generated as follows: √ √ uk + vk N = (u1 + v1 N )k , k = 0, 1, 2, . . . ; (4.8) see, for example, [1, page 76]. 176 EVEN AND ODD PERIODS IN CONTINUED FRACTIONS OF SQUARE ROOTS Lemma 6: If uk , vk are defined as above, then for k, j ≥ 1 with j odd. (uk , vj ) = 1, Proof: We can write (4.8) in matrix form as: uk 1 u1 k =M , where M = vk 0 v1 v1 N u1 . (4.9) Note that detM = ±1. Using (4.9) and M −1 =± u1 −v1 −v1 N u1 , we can extend the definition of uk , vk to all integer subscripts k. It is easy to see that |u−k | uk = , for k = 1, 2, . . . (4.10) |v−k | vk It is also straightforward to prove by induction that, for d = 1, 2, . . . , Ud Vd N d , for integers Ud and Vd . M = Vd Ud For d ≥ 1 and k ∈ Z, we can use M d and M −d to obtain uk+d Ud uk + Vd N vk uk−d Ud uk − Vd N vk = and =± . vk+d Vd uk + Ud vk vk−d −Vd uk + Ud vk Hence uk+d vk+d = uk−d vk−d + 2Vd N vk 2Vd uk . (4.11) It follows from (4.11) that (uk+d , vk ) > 1 if and only if (uk−d , vk ) > 1, (4.12) (vk+d , vk ) > 1 if and only if (4.13) and (vk−d , uk ) > 1. Suppose now that (uk , vj ) > 1 for some k, j ≥ 0 with j odd, and assume that d = |k − j| is minimal. Clearly d ≥ 1, since (uk , vk ) = 1. By induction, we deduce from (4.12) and (4.13) that (uj+(2i−1)d , vj+2id ) > 1 and (uj+(2i+1)d , vj+2id ) > 1, for i ∈ Z. Now j + 2id is odd for all i and in particular j + 2id is never 0. Also j + (2i ± 1)d is never 0, since u0 = 1. Thus, for some value of i, j + (2i − 1)d < 0 < j + 2id or 177 j + 2id < 0 < j + (2i + 1)d. EVEN AND ODD PERIODS IN CONTINUED FRACTIONS OF SQUARE ROOTS In either case, it follows by (4.10) that there exist k 0 and j 0 with j 0 odd and d0 = |k 0 − j 0 | < d such that (uk0 , vj 0 ) > 1, which is a contradiction. This proves Lemma 6. We now complete the proof of Theorem 3. Suppose first that condition (a) holds; that is, x2 r − y 2 s = ±2, for some odd x, y. Then the pair (r, s) is congruent modulo 4 to (2,0), (0,2), (3,1) or (1,3). In each case, we deduce by Theorem C, part (b) that l(N ) is even. Suppose next that condition (b) holds; that is, r, s 6= 1 and x2 r − y 2 s = ±1, for some x, y ∈ Z. Write r = a2 ρ and s = b2 σ, where ρ and σ are squarefree. If ρ, σ > 1, then l(ρσ) is even, by Lemma 5, so l(N ) is even by Lemma 4. Thus we need only consider the case that ρ = 1 and σ > 1. Then a > 1, N = a2 b2 σ and (xa)2 − (yb)2 σ = ±1. (4.14) If l(N ) is odd, then l(σ) is odd, by Lemma 4. Thus, by Theorem B, there exist minimal positive integers u and v such that u2 − v 2 σ = −1, and positive integers U and V such that U 2 − V 2 N = U 2 − (V ab)2 σ = −1. Hence, by (4.14) and (4.8), we have √ √ xa + yb σ = (u + v σ)k √ √ and U + V ab σ = (u + v σ)j , where k, j ≥ 0, with j odd; see [1, page 76]. Since (xa, V ab) ≥ a > 1 and j is odd, we obtain a contradiction to Lemma 6. Therefore l(N ) is even, as required. Remark: In Lemma 3 we saw that if A is odd, then case (a) of Theorem 3 occurs, whereas if A is even, then case (b) of Theorem 3 occurs. In fact, the converse statements also hold, so the two conditions in Theorem 3 are mutually exclusive. This can be shown using the identity (x2 r − y 2 s)2 = (x2 r + y 2 s)2 − 4rsx2 y 2 , together with the fact that if l(N ) is even and x = u1 , y = v1 are the minimal positive solutions of x2 − N y 2 = 1, then v1 = A and the remaining solutions can be expressed in terms of u1 and v1 using Chebyshev polynomials of the first and second kind; see [4, page 232]. We omit the details. Now we prove Corollary 1. By Theorem 3, part (a), we may assume that x is even. Then y is odd and s is even. With x = 2ξ and s = 2σ, we obtain ξ 2 (2r) − y 2 σ = ±1. Since N = 2rσ, 2r 6= 1 and σ = 21 s 6= 1, it follows by Theorem 3, part (b) that l(N ) is even, as required. Finally, we prove Corollary 2. To prove part (a), we assume that l(N ) is even and seek a contradiction. Then case (a) or case (b) of Theorem 3 must hold. Case (a) does not hold, since x2 r and y 2 s cannot have the same parity. Thus case (b) holds, so N = rs, where r, s 6= 1 and x2 r − y 2 s = ±1, for some x, y ∈ Z. (4.15) We may now assume that r = 2 and s = pt , so 2x2 ≡ ±1 (mod p). Since p is prime this implies that 2 or −2 is a quadratic residue (mod p). This is impossible, however, since both 2 178 EVEN AND ODD PERIODS IN CONTINUED FRACTIONS OF SQUARE ROOTS and −2 are quadratic non-residues (mod p) by Gauss’ lemma [2, page 68]. Indeed, for a = 2 and a = −2, exactly 41 (p − 1) of the numbers a, 2a, . . . , 12 (p − 1)a are congruent (mod p) to numbers in the interval (− 12 p, 0), and 14 (p − 1) is odd. To prove part (b), we must again obtain a contradiction to the factorisation N = rs, where (4.15) holds. We may now assume that either r = 2 or r = 2pt11 . If r = 2, then 2x2 ≡ ±1 (mod p1 ), so we can again obtain a contradiction using Gauss’ lemma. If r = 2pt11 , then s = pt22 and y is odd, so x2 r ≡ 0 or 2 (mod 8) and y 2 s ≡ 5 (mod 8), which contradicts (4.15). The proof of part (c) uses Gauss’ lemma again, in a similar way to that of part (a). 5. ALTERNATIVE APPROACHES There are alternative ways to view some of the formulas in Lemmas 2 and 3, which we mention here. First, recall that the complete quotients of an irrational number α are defined as: 1 (n = 0, 1, 2, . . . ), αn − an √ where an = [αn ]. It can be shown (see, for example, [5]) that if α = N , then √ Pn + N αn = , for n = 0, 1, 2, . . . , Qn α0 = α, αn+1 = (5.1) where P0 = 0, Q0 = 1, Pn+1 = an Qn − Pn , Qn+1 = 2 N − Pn+1 , Qn and, in terms of the quantities in (2.2), we have An An−1 1 Pn+1 An = Bn Bn−1 0 Qn+1 Bn N Bn An for n = 0, 1, 2, . . . , , for n = 0, 1, 2, . . . . (5.2) (5.3) In particular, Pn+1 = (−1)n (An An−1 − Bn Bn−1 N ), for n = 0, 1, 2, . . . , (5.4) and Qn+1 = (−1)n+1 (A2n − Bn2 N ), for n = 0, 1, 2, . . . . (5.5) Therefore in Lemma 2, with l(N ) = 2m + 1, the identity N = u2 + v 2 , where u and v 2 are given by (3.5) and (3.6), can be expressed as N = Pm+1 + Q2m+1 , so it is equivalent to the identity Qm = Qm+1 , by (5.2). When l(N ) = 2m + 1, another approach to obtaining the equation N = u2 + v 2 , where u and v are given by (3.2) and (3.3), is to start from the equation N = a20 + (2a0 B + C)/A in the proof of Lemma 1, and use (3.7) and (3.8) to obtain AN = (a0 pm + qm )2 + (a0 pm−1 + qm−1 )2 = A2m + A2m−1 . 179 (5.6) EVEN AND ODD PERIODS IN CONTINUED FRACTIONS OF SQUARE ROOTS This equation is also equivalent to Qm = Qm+1 , by (5.5). If u and v are defined by Am pm pm−1 u = , Am−1 −pm−1 pm v (5.7) then A2m + A2m−1 = A(u2 + v 2 ), so N = u2 + v 2 . It is now easy to see from (5.7) that u and v are given by (3.2) and (3.3), though this derivation does not show immediately that u and v are integers. However, by Lemma 1, we have a0 = 21 BC + kA, where k ∈ Z, since l(N ) is odd and A is odd by Theorem 1. By substituting for a0 in (3.2) and (3.3), and using (3.8), we obtain the following formulas which do show that u and v are integers: u= = 1 BC − qm−1 (Bqm−1 + 2(−1)m qm ) + (p2m − p2m−1 )k 2 1 3 3 (pm qm − pm−1 qm−1 + 3qm−1 qm (−1)m ) + (p2m − p2m−1 )k 2 and 2 v = Cpm−1 qm + (−1)m qm−1 + 2pm pm−1 k 3 3 = pm−1 qm + pm qm−1 + 2pm pm−1 k. Finally, it is shown in [5, page 54] that if l(N ) = 2m + 2, then Pm+1 = Pm+2 . By (5.4), this identity is equivalent to N= Am (Am+1 + Am−1 ) , Bm (Bm+1 + Bm−1 ) which is Lemma 3, part (b). REFERENCES [1] A. Baker. A Concise Introduction to the Theory of Numbers. Cambridge University Press, Cambridge, 1984. [2] H. Davenport. The Higher Arithmetic. Cambridge University Press, Cambridge, 1993. [3] O. Perron. Die Lehre von der Kettenbruchen. Chelsea Publishing Company, New York, 1950. [4] T. J. Rivlin. Chebyshev Polynomials. John Wiley, New York, 1990. [5] A.J. van der Poorten & P.G. Walsh. “A Note on Jacobi Symbols and Continued Fractions.” American Mathematical Monthly 106.1 (1999): 52-56. AMS Classification Numbers: 11A55 zzz 180