This is the problem:

Does there exist positive integer $d$ ( which is not a perfect square ) such that the length of the least period in the simple continued fraction of $\sqrt{d}$ is $3$?

Consider the following theorem

Theorem : If the positive integer $d$ is not a perfect square, the simple continued fraction of $\sqrt{d}$ has the form $\sqrt{d} = [a_0;\overline{a_1,a_2,\cdots,a_{r-1},2a_o}]$ with $a_o = \lfloor d \rfloor$. Here $r$ denotes the length of the least period in the expansion of $\sqrt{d}$. Where $\lfloor x \rfloor$ denotes the greatest integer function/ floor function of $x$.

We want to solve for non-square $d$ where$\sqrt{d} = [a_0;\overline{a_1,a_2,2a_o}]$, and $a_o = \lfloor d \rfloor$. Since $d$ is a positive integer, $a_o = \lfloor d \rfloor \ge 1$, and $a_1 , a_2$ are positive integers by definition. Please note that the converse of the above theorem is not true, for example, consider $[1;\overline{1,1,2}] = \sqrt{10}/2$ and $[0;\overline{1,1,0}] = \sqrt{2}/2$. I calculated first few continued fractions for $\sqrt{d}$, $$\begin{array}{c|c|c} \sqrt{d} & \text{Continued fraction} & r\\ \hline √2 & [1;\bar{2}] & 1 \\ √3 & [1;\overline{1,2}] & 2 \\ √5 & [2;\bar{4}] & 1\\ √6 & [2;\overline{2,4}] & 2\\ √7 & [2;\overline{1,1,1,4}] & 4\\ √8 & [2;\overline{1,4}] & 2\\ √10 & [3;\bar{6}] & 1\\ √11 & [3;\overline{3,6}] & 2\\ √12 & [3;\overline{2,6}] & 2\\ √13 & [3;\overline{1,1,1,1,6}] & 5\\ √14 & [3;\overline{1,2,1,6}] & 4\\ √15 & [3;\overline{1,6}] & 2\\ √17 & [4;\bar{8}] & 1\\ √18 & [4;\overline{4,8}] & 2\\ √19 & [4;\overline{2,1,3,1,2,8}] & 6 \\ √20 & [4;\overline{2,8}] & 2\\ √21 & [4;\overline{1,1,2,1,1,8}] & 6\\ √22 & [4;\overline{1,2,4,2,1,8}] & 6\\ √23 & [4;\overline{1,3,1,8}] & 4\\ √24 & [4;\overline{1,8}] & 2\\ \end{array}$$

As we can see for $1< d \le 24, r \ne 3$. Also, on a side note, observe that there does not exist two consecutive intergers $d$ and $d+1$ such that both $\sqrt{d}$ and $\sqrt{d+1}$ have $r=1$, moreover there are infinitely $\sqrt{d}$ such that the length of there least period is $1$ or $2$, $\sqrt{n^2+1} = [n;\overline{2n}]$, $\sqrt{n^2+2} = [n;\overline{n,2n}]$ and $\sqrt{n^2-1} = [n-1;\overline{1,2(n-1)}]$ , where $n \in \mathbb{N}$ .Even for $r=4$, we have $\sqrt{n^2-2} = [n-1; \overline{1,n-2,1,2(n-1)}]$, $n>2$. Now i have a hunch that no such $d$ exists for which $\sqrt{d}$ have $r=3$. Any hints on how to prove this ? In general does there exist a number $m$ such that $r\ne m $ for any $\sqrt{d}$ ?

  • 6
    $\begingroup$ According to oeis the least such is $41$. The tabulated sequence is here. $\sqrt {41}=[6; \overline {2,2,12}]$. $\endgroup$ – lulu Nov 8 '19 at 21:23
  • $\begingroup$ Thank you :) . Are there infinitely many such numbers? @lulu $\endgroup$ – Sabhrant Nov 8 '19 at 21:31
  • 1
    $\begingroup$ Move this to an answer, maybe? $\endgroup$ – Oscar Lanzi Nov 8 '19 at 21:33
  • 2
    $\begingroup$ There appear to be infinitely many, see this $\endgroup$ – lulu Nov 8 '19 at 21:38
  • 1
    $\begingroup$ There is also $\sqrt{n(n+1)}=[n;\overline{2,2n}]$. The case $n=1$ is "hidden" because $\overline{2,2}$ reduces to $\overline{2}$. $\endgroup$ – Oscar Lanzi Nov 8 '19 at 21:49

Yes there are infinitely many. And it is not difficult to find them.

We seek continued fractions of the form


First off, add $a$ to get a "pure" periodic expression. We shall call the quadratic surd $x$:


We may then render


and upon clearing fractions


Now comes the sneaky part. If the above quadratic equation over the integers is to have a root $a+\sqrt{N}$, its other root must be $a-\sqrt{N}$ forcing the linear coefficient to be exactly $-2a$ times the quadratic one! Thereby $b=c$ above and the quadratic equation simplifies to:


This gives an integer radicand whenever $2ab+1$ is a multiple of $b^2+1$, in which cases the common factor of $b^2+1$ may be cancelled from the quadratic equation leaving the equation monic.

Suppose, for example, we drop in $b=2$. Then $2ab+1$ is to be a multiple of $5$ and $a$ can be any whole number one greater than a multiple of $5$. Putting $a=1$ results in the "trivial" solution $\sqrt{2}=[1,\overline{2}]$, as the period is reduced from three to one due to $b=c=2a$. But this equality is avoided for larger eligible values of $a$ and we get a series of period $3$ solutions. In all cases $N$ is one fourth the discriminant of the monic polynomial obtained after cancelling out the $b^2+1$ factor:

$a=6\to \sqrt{41}=[6,\overline{2,2,12}]$

$a=11\to \sqrt{130}=[11,\overline{2,2,22}]$

$a=5k+1\to \sqrt{25k^2+14k+2}=[5k+1,\overline{2,2,10k+2}]$

There are more families of solutions like this with other values of $b$. Just put in an even positive value for $b$ (why even?) and turn the crank. You must put $a>b/2$ to avoid the collapse we saw above with $\sqrt{2}$.

So much for a repeat petiod of $3$, what about larger periods?

Claim: For any positive whole numbers $r$ there are at least an infinitude of $\sqrt{N}$ continued fractions having repeat period $r$ where $N$ is a whole number, having the following form:


$P_r$ is a Pell number defined by $P_0=0,P_1=P_{-1}=1,P_r=2P_{r-1}+P_{r-2}\text{ for } r\ge 2$, and $k$ is a whole number $\ge 0$ for $r=1$, $\ge 1$ otherwise. The number of $2$ digits before the final entries is $r-1$.

The proof bears some similarities to calcukating the general solution for $r=3$ above. First add $kP_r+1$ to the expression to make a purely periodic fraction:




By mathematical induction on $r$ and using the recursive relation defined for Pell numbers in the claim it is true that


with $r-1$ $2$ digits in the block. When this is substituted into the previous equation this is obtained:




Upon completing the square and back-substitutinging $\sqrt{N}=x-(P_rk+1)$ we obtain:


Using the Pell number recursion to eliminste $P_{r-2}$:


thereby identifying $N$ as a whole number. For a full fundamental period $\ge 2$ the terminal element must not match the other elements, so in that case $k\ge 1$. Else ( meaning a period of just $1$), $k$ may be any whole number, $k\ge 0$.


Just working numerically, $41$ is the least example, with $$\sqrt {41}=[6; \overline {2,2,12}]$$

here is a tabulated list of the periods of $\sqrt d$.

OEIS provides a list of $d$ for which the period is $3$, and that link provides a way of generating infinitely many examples.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.