TITLE: Is there an elementary proof of a result about the parity of the period of the repeating block in the continued fraction expansion of square roots
QUESTION [15 upvotes]: It is a known fact that for a Prime $P$, $P\equiv 1$ mod $4$ iff the length of the period in the repeating block for the continued fraction expansion of $\sqrt{P}$ is odd.  I have an elementary proof of this using the classical result: $P\equiv 1$ mod $4$ iff $x^2-Py^2=-1$ has integer solutions and a proof that $x^2-Py^2=-1$ has integer solutions iff the length of the period in the repeating block for the continued fraction expansion of $\sqrt{P}$ is odd.  
I have tried repeatedly to give a direct elementary proof that $P\equiv 1$ mod $4$ implies that the length of the period in the repeating block for the continued fraction expansion of $\sqrt{P}$ is odd, but cant seem to figure it out.  (I have a direct elementary proof of the converse)
Does anyone know of an elementary proof of this result or where I may find one?

REPLY [3 votes]: See Nagell, Introduction to number theory, Theorem 107. Originally it was proved by Legendre, see Dickson, L. E. History of the theory of numbers. Vol. II, p. 365. There are more examples due to Dirichlet, see Dirichlet's Werke, Bd. 1 (1889), pp. 219-236.
An extended bibliography on negative Pell’s equation can be found in Gerasim, I.-Kh.I.
On the genesis of Redei’s theory of the equation x 2 -Dy 2 =-1. (Russian) Zbl 0731.01014
Istor.-Mat. Issled. 32/33, 199-211 (1990) (available in electronic form).