This site is supported by donations to The OEIS Foundation.

# Continued fractions

(Redirected from Simple continued fractions)

The unqualified term continued fraction implies simple continued fraction (also called regular continued fraction).

## Simple continued fractions

### Finite simple continued fractions

A finite simple continued fraction is an expression of the form

$c = a_0 + \underset{k=1}{\overset{n}{\rm K}} ~ \frac{1}{a_k} := a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{ \ddots \cfrac{\ddots}{a_{n-1} + \cfrac{1}{a_n}}}}}, \,$

where $\scriptstyle a_0 \,$ is the integer part of the continued fraction, the partial quotients $\scriptstyle a_k,\, 1 \,\le\, k \,\le\, n,\, \,$ are positive integers, and $\scriptstyle n \,$ is a positive integer. (See Gauss' Kettenbruch notation for the continued fraction operator $\scriptstyle {\rm K}. \,$)

Finite simple continued fractions obviously represent rational numbers, and every rational number can be represented in precisely one way as a finite simple continued fraction.

### Infinite simple continued fractions

A infinite simple continued fraction is an expression of the form

$c = a_0 + \underset{k=1}{\overset{\infty}{\rm K}} ~ \frac{1}{a_k} := a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{a_3 + \cfrac{1}{a_4 + \cfrac{1}{\ddots}}}}}, \,$

where $\scriptstyle a_0 \,$ is the integer part of the continued fraction and the partial quotients $\scriptstyle a_k,\, k \,\ge\, 1,\, \,$ are positive integers. (See Gauss' Kettenbruch notation for the continued fraction operator $\scriptstyle {\rm K}. \,$)

A compact representation is

$c = a_0 + 1/(a_1 + 1/(a_2 + 1/(a_3 + 1/(a_4 + 1/(a_5 + 1/(a_6 + \ldots)))))) \,$

A compact notation is

$c = [a_0; a_1, a_2, a_3, a_4, a_5, a_6, \ldots] \,$

A sequence representation is

$\{ a_0, a_1, a_2, a_3, a_4, a_5, a_6, \ldots \} \,$

Every infinite simple continued fraction represent an irrational number, and every irrational number can be represented in precisely one way as an infinite simple continued fraction.

#### Eventually periodic infinite simple continued fractions

Every eventually periodic infinite simple continued fraction represent an irrational quadratic number (root of an irreducible quadratic polynomial with integer coefficients), and every irrational quadratic number can be represented in precisely one way as an eventually periodic infinite simple continued fraction, i.e.

$c = [a_0; a_1, a_2, a_3, a_4, a_5, a_6, \ldots] \,$

and, for some integer $\scriptstyle m \,$ and some integer $\scriptstyle k \,>\, 0 \,$, we have $\scriptstyle a_n \,=\, a_{\{n+k\}} \,$ for all $\scriptstyle n \,\ge\, m \,$.

All non-quadratic irrational numbers have non-periodic infinite simple continued fractions.

### Simple continued fractions convergents

An infinite simple continued fraction representation for an irrational number is mainly useful because its initial segments provide excellent rational approximations to the number. These rational numbers are called the convergents of the continued fraction. Even-numbered convergents are smaller than the original number, while odd-numbered ones are bigger.

The first few convergents (numbered from 0) are

$c_0 = \frac{p_0}{q_0} = \frac{a_0}{1},\ c_1 = \frac{p_1}{q_1} = \frac{a_1 a_0 + 1}{a_1},\ c_2 = \frac{p_2}{q_2} = \frac{a_2(a_1 a_0 + 1)+a_0}{a_2 a_1 + 1},\ c_3 = \frac{p_3}{q_3} = \frac{a_3(a_2(a_1 a_0 + 1)+a_0)+(a_1 a_0 + 1)}{a_3(a_2 a_1 + 1)+a_1},\ \ldots \,$

or equivalently

$c_0 = \frac{p_0}{q_0} = \frac{a_0 p_{-1} + p_{-2}}{a_0 q_{-1} + q_{-2}} = \frac{a_0}{1},\ c_1 = \frac{p_1}{q_1} = \frac{a_1 p_0 + p_{-1}}{a_1 q_0 + q_{-1}},\ c_2 = \frac{p_2}{q_2} = \frac{a_2 p_1 + p_0}{a_2 q_1 + q_0},\ c_3 = \frac{p_3}{q_3} = \frac{a_3 p_2 + p_1}{a_3 q_2 + q_1},\ \ldots \,$

with

$p_{-2} = 0,\, q_{-2} = 1, \,$ i.e. $c_{-2} = \frac{p_{-2}}{q_{-2}} = \frac{0}{1} = 0 \,$
$p_{-1} = 1,\, q_{-1} = 0, \,$ i.e. $c_{-1} = \frac{p_{-1}}{q_{-1}} = \frac{1}{0} = \infty \,$

giving

$p_n = a_n p_{n-1} + p_{n-2} \,$
$q_n = a_n q_{n-1} + q_{n-2} \,$

with

$p_{-2} = 0,\, q_{-2} = 1, \,$ i.e. $c_{-2} = \frac{p_{-2}}{q_{-2}} = \frac{0}{1} = 0 \,$
$p_{-1} = 1,\, q_{-1} = 0, \,$ i.e. $c_{-1} = \frac{p_{-1}}{q_{-1}} = \frac{1}{0} = \infty \,$

where

$c_n = \frac{p_n}{q_n},\, n \ge -2. \,$
$\lim_{n \to \infty} c_n = c \quad {\rm iff} \quad \lim_{n \to \infty} \sum_{k=0}^{n} a_k \to \infty \,$

These recurrence relations (a special case of generalized continued fractions convergents) are due to John Wallis.

Table of nice simple continued fractions
Continued fraction Closed form Decimal expansion A-number
$1 + \underset{k=1}{\overset{\infty}{\rm K}} ~ \frac{1}{1} = 1 + \cfrac{1}{1 + \cfrac{1}{1 + \cfrac{1}{1 + \cfrac{1}{\ddots}}}} \,$

{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...}

Phi
Golden ratio

$\varphi = \frac{1 + \sqrt{5}}{2} \,$

1.618033988749894848204586834...

CF:
A000012

Conv. nums:
$\scriptstyle p_n \,=\, \,$ A000045$\scriptstyle (n+2),\, n \,\ge\, 0 \,$

Conv. dens:
$\scriptstyle q_n \,=\, \,$ A000045$\scriptstyle (n+1),\, n \,\ge\, 0 \,$

Base 10:
A001622

$0 + \underset{k=1}{\overset{\infty}{\rm K}} ~ \frac{1}{1 + (\frac{2k}{3} - 1) \cdot 0^{(k \bmod 3)}} = \textbf{0} + \cfrac{1}{1 + \cfrac{1}{1 + \cfrac{1}{\textbf{2} + \cfrac{1}{1 + \cfrac{1}{1 + \cfrac{1}{\textbf{4} + \cfrac{1}{1 + \cfrac{1}{\ddots}}}}}}}} \,$

{0, 1, 1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, 1, 1, 10, 1, 1, 12, 1, 1, 14, ...}

1/(e-1)

$\frac{1}{e-1} = \sum_{n=1}^{\infty} e^{-n} \,$

0.5819767068693264243850020051...

CF:
$\scriptstyle a(n) \,=\, \,$ A005131$\scriptstyle (n+1),\, n \,\ge\, 0 \,$

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A073333

$1 + \underset{k=1}{\overset{\infty}{\rm K}} ~ \frac{1}{1 + \frac{4k}{3} \cdot 0^{(k \bmod 3)}} = \textbf{1} + \cfrac{1}{1 + \cfrac{1}{1 + \cfrac{1}{\textbf{5} + \cfrac{1}{1 + \cfrac{1}{1 + \cfrac{1}{\textbf{9} + \cfrac{1}{1 + \cfrac{1}{\ddots}}}}}}}} \,$

{1, 1, 1, 5, 1, 1, 9, 1, 1, 13, 1, 1, 17, 1, 1, 21, 1, 1, 25, 1, 1, 29, ...}

1/(sqrt(e)-1)

$\frac{1}{\sqrt{e} - 1} \,$

1.54149408253679828413110344447...

CF:
$\scriptstyle a(n) \,=\, \,$ A058281$\scriptstyle (n+1),\, n \,\ge\, 0 \,$

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A113011

$0 + \underset{k=1}{\overset{\infty}{\rm K}} ~ \frac{1}{2(2k-1)} = 0 + \cfrac{1}{2 + \cfrac{1}{6 + \cfrac{1}{10 + \cfrac{1}{14 + \cfrac{1}{18 + \cfrac{1}{22 + \cfrac{1}{26 + \cfrac{1}{\ddots}}}}}}}} \,$

{0, 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, ...}

tanh(1/2) = (e-1)/(e+1)

$\tanh(\tfrac{1}{2}) = \frac{e - 1}{e + 1} \,$

0.46211715726000975850231848364...

CF:
$\scriptstyle a(n) \,=\, \,$ A016825$\scriptstyle (n-1),\, n \,\ge\, 1 \,$

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A160327

$0 + \underset{k=1}{\overset{\infty}{\rm K}} ~ \frac{1}{k} = 0 + \cfrac{1}{1 + \cfrac{1}{2 + \cfrac{1}{3 + \cfrac{1}{4 + \cfrac{1}{5 + \cfrac{1}{6 + \cfrac{1}{7 + \cfrac{1}{\ddots}}}}}}}} \,$

0+1/(1+1/(2+1/(3+1/(4+1/(5+...)))))

{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, ...}

?

$? \,$

0.697774657964007982006790592...

CF:
A001477

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A052119

$1 + \underset{k=1}{\overset{\infty}{\rm K}} ~ \frac{1}{k+1} = 1 + \cfrac{1}{2 + \cfrac{1}{3 + \cfrac{1}{4 + \cfrac{1}{5 + \cfrac{1}{6 + \cfrac{1}{7 + \cfrac{1}{8 + \cfrac{1}{\ddots}}}}}}}} \,$

1+1/(2+1/(3+1/(4+1/(5+...))))

{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, ...}

?

$? \,$

1.433127426722311758317183455...

CF:
A000027

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A060997

$p_1 + \underset{k=1}{\overset{\infty}{\rm K}} ~ \frac{1}{p_{k+1}} = 2 + \cfrac{1}{3 + \cfrac{1}{5 + \cfrac{1}{7 + \cfrac{1}{11 + \cfrac{1}{13 + \cfrac{1}{17 + \cfrac{1}{19 + \cfrac{1}{\ddots}}}}}}}} \,$

2+1/(3+1/(5+1/(7+1/(11+...))))

{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, ...}

?

$? \,$

2.3130367364335829063839516...

CF:
A000040

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A064442

## Generalized continued fractions

Generalized continued fractions are also called general continued fractions.

### Finite generalized continued fractions

A finite generalized continued fraction is an expression of the form

$c = a_0 + \underset{k=1}{\overset{n}{\rm K}} ~ \frac{b_k}{a_k} := a_0 + \cfrac{b_1}{a_1 + \cfrac{b_2}{a_2 + \cfrac{b_3}{ \ddots \cfrac{\ddots}{a_{n-1} + \cfrac{b_n}{a_n}}}}}, \,$

where $\scriptstyle a_0 \,$ is the integer part of the continued fraction, the $\scriptstyle b_k,\, 1 \,\le\, k \,\le\, n,\, \,$ are the partial numerators, the $\scriptstyle a_k,\, 1 \,\le\, k \,\le\, n,\, \,$ are the partial denominators, and $\scriptstyle n \,$ is a positive integer. (See Gauss' Kettenbruch notation for the continued fraction operator $\scriptstyle {\rm K}. \,$)

Finite generalized continued fractions obviously represent rational numbers, although rational numbers can be represented in many (finitely many?) ways as a finite generalized continued fraction.

### Infinite generalized continued fractions

A infinite generalized continued fraction is an expression of the form

$c = a_0 + \underset{k=1}{\overset{\infty}{\rm K}} ~ \frac{b_k}{a_k} := a_0 + \cfrac{b_1}{a_1 + \cfrac{b_2}{a_2 + \cfrac{b_3}{a_3 + \cfrac{b_4}{a_4 + \cfrac{b_5}{\ddots}}}}}, \,$

where $\scriptstyle a_0 \,$ is the integer part of the continued fraction, the $\scriptstyle b_k,\, k \,\ge\, 1,\, \,$ are the partial numerators, the $\scriptstyle a_k,\, k \,\ge\, 1,\, \,$ are the partial denominators. (See Gauss' Kettenbruch notation for the continued fraction operator $\scriptstyle {\rm K}. \,$)

A compact representation is

$c = a_0 + b_1/(a_1 + b_2/(a_2 + b_3/(a_3 + b_4/(a_4 + b_5/(a_5 + b_6/(a_6 + \ldots)))))) \,$

A compact notation could be

$c = [a_0; b_1/a_1, b_2/a_2, b_3/a_3, b_4/a_4, b_5/a_5, b_6/a_6, \ldots] \,$

A sequence representation could be

$\{ a_0, b_1, a_1, b_2, a_2, b_3, a_3, b_4, a_4, b_5, a_5, b_6, a_6, \ldots \} \,$

Every infinite generalized continued fraction represent an irrational number, although irrational numbers can be represented in many (infinitely many?) ways as an infinite generalized continued fraction.

#### ??? Eventually periodic infinite generalized continued fractions ???

The numbers having at least one eventually periodic infinite generalized continued fraction representation are... ?????

where

$c = [a_0; b_1/a_1, b_2/a_2, b_3/a_3, b_4/a_4, b_5/a_5, b_6/a_6, \ldots] \,$

and, for some integer $\scriptstyle m \,$ and some integer $\scriptstyle k \,>\, 0 \,$, we have $\scriptstyle \frac{b_n}{a_n} \,=\, \frac{b_{\{n+k\}}}{a_{\{n+k\}}} \,$ for all $\scriptstyle n \,\ge\, m \,$.

The numbers with only non-periodic infinite generalized continued fraction representations are ?????. (Are there such numbers...?)

### Generalized continued fractions convergents

The first few convergents (numbered from 0) are

$c_0 = \frac{p_0}{q_0} = \frac{a_0}{1},\ c_1 = \frac{p_1}{q_1} = \frac{a_1 a_0 + b_1}{a_1},\ c_2 = \frac{p_2}{q_2} = \frac{a_2(a_1 a_0 + b_1) + b_2 a_0}{a_2 a_1 + b_2},\ c_3 = \frac{p_3}{q_3} = \frac{a_3(a_2(a_1 a_0 + b_1) + b_2 a_0) + b_3(a_1 a_0 + b_1)}{a_3(a_2 a_1 + b_2) + b_3 a_1},\ \ldots \,$

or equivalently

$c_0 = \frac{p_0}{q_0} = \frac{a_0 p_{-1} + b_0 p_{-2}}{a_0 q_{-1} + b_0 q_{-2}} = \frac{a_0}{1},\, c_1 = \frac{p_1}{q_1} = \frac{a_1 p_0 + b_1 p_{-1}}{a_1 q_0 + b_1 q_{-1}},\, c_2 = \frac{p_2}{q_2} = \frac{a_2 p_1 + b_2 p_0}{a_2 q_1 + b_2 q_0},\, c_3 = \frac{p_3}{q_3} = \frac{a_3 p_2 + b_3 p_1}{a_3 q_2 + b_3 q_1},\, \ldots \,$

with

$b_0 \equiv 1 \,$
$p_{-2} \equiv,\, q_{-2} \equiv 1, \,$ i.e. $c_{-2} \equiv \frac{p_{-2}}{q_{-2}} = \frac{0}{1} = 0 \,$
$p_{-1} \equiv,\, q_{-1} \equiv 0, \,$ i.e. $c_{-1} \equiv \frac{p_{-1}}{q_{-1}} = \frac{1}{0} = \infty \,$

giving

$p_n = a_{n} p_{n-1} + b_{n} p_{n-2} \,$
$q_n = a_{n} q_{n-1} + b_{n} q_{n-2} \,$

with

$b_0 \equiv 1 \,$
$p_{-2} \equiv,\, q_{-2} \equiv 1, \,$ i.e. $c_{-2} \equiv \frac{p_{-2}}{q_{-2}} = \frac{0}{1} = 0 \,$
$p_{-1} \equiv,\, q_{-1} \equiv 0, \,$ i.e. $c_{-1} \equiv \frac{p_{-1}}{q_{-1}} = \frac{1}{0} = \infty \,$

where

$c_n = \frac{p_n}{q_n},\, n \ge -2. \,$
$c = \lim_{n \to \infty} c_n \,$

These recurrence relations are due to John Wallis.

Table of nice generalized continued fractions
Continued fraction Closed form Decimal expansion A-number
$1 + \underset{k=1}{\overset{\infty}{\rm K}} ~ \frac{k}{1} = 1 + \cfrac{1}{1 + \cfrac{2}{1 + \cfrac{3}{1 + \cfrac{4}{\ddots}}}} \,$

1+1/(1+2/(1+3/(1+4/(1+...))))

{1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, ...}

sqrt(2/(pi*e))/erfc(1/sqrt(2))

$\sqrt{\frac{2}{\pi e}} \frac{1}{{\rm ~erfc}(\tfrac{1}{\sqrt{2}})} \,$

1.525135276160981209089090536...

CF:
$\scriptstyle a(n) \,=\, \,$ A057979$\scriptstyle (n+2),\, n \,\ge\, 0 \,$

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A111129

$0 + \underset{k=1}{\overset{\infty}{\rm K}} ~ \frac{k}{k} = 0 + \cfrac{1}{1 + \cfrac{2}{2 + \cfrac{3}{3 + \cfrac{4}{\ddots}}}} \,$

0+1/(1+2/(2+3/(3+4/(4+...))))

{0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, ...}

1/(e-1)

$\frac{1}{e-1} = \sum_{n=1}^{\infty} e^{-n} \,$

0.5819767068693264243850020051...

CF:
A110654

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A073333

$1 + \underset{k=1}{\overset{\infty}{\rm K}} ~ \frac{2k}{2k+1} = 1 + \cfrac{2}{3 + \cfrac{4}{5 + \cfrac{6}{7 + \cfrac{8}{\ddots}}}} \,$

1+2/(3+4/(5+6/(7+8/(9+...))))

{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, ...}

1/(sqrt(e)-1)

$\frac{1}{\sqrt{e}-1} \,$

1.54149408253679828413110344447...

CF:
A000027

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A113011

$1 + \underset{k=1}{\overset{\infty}{\rm K}} ~ \frac{k^2}{2k+1} = 1 + \cfrac{1}{3 + \cfrac{4}{5 + \cfrac{9}{7 + \cfrac{16}{\ddots}}}} \,$

1+1/(3+4/(5+9/(7+16/(9+...))))

{1, 1, 3, 4, 5, 9, 7, 16, 9, 25, 11, 36, 13, 49, 15, 64, 17, 81, ...}

4/pi

$\frac{4}{\pi} \,$

1.27323954473516268615107010698...

CF:
A079097

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A088538

$p_1 + \underset{k=1}{\overset{\infty}{\rm K}} ~ \frac{p_{2k}}{p_{2k+1}} = 2 + \cfrac{3}{5 + \cfrac{7}{11 + \cfrac{13}{17 + \cfrac{19}{\ddots}}}} \,$

2+3/(5+7/(11+13/(17+19/(23+...))))

{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, ...}

Herkommer number

$? \,$

2.5360270816893383923069490821...

CF:
A000040

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A085825

## Gauss' Kettenbruch notation

Karl Friedrich Gauss evoked the more familiar product operator $\scriptstyle \prod \,$ when he devised his notation for the continued fraction (Kettenbruch in german) operator

$x = a_0 + \underset{k=1}{\overset{\infty}{\rm K}} ~ \frac{b_k}{a_k} := a_0 + \cfrac{b_1}{a_1 + \cfrac{b_2}{a_2 + \cfrac{b_3}{a_3 + \cfrac{b_4}{a_4 + \cfrac{b_5}{\ddots}}}}}. \,$

Here the $\scriptstyle {\rm K} \,$ stands for Kettenbruch, the German word for "continued fraction." This is probably the most compact and convenient way to express continued fractions; however, it is not widely used by English typesetters.