# Examples and counterexamples in mathematics/Infinite sequences

296280 more-or-less notable sequences are collected on The On-Line Encyclopedia of Integer Sequences. See also mathigon, mathsisfun etc.

## A sequence of equal members

(0,0,0,0,...)
Unlike a set, a sequence may contain nothing but zero and still be infinite. That is, all members (in other words, elements or terms) of a sequence may be equal to 0; or, say, to 71, if you prefer: (71,71,71,71,...).

## The sequence of natural numbers

(1,2,3,...)
The n-th member is equal to n.
This sequence is strictly increasing (that is, each member is less than the next member).
The odd subsequence (1,3,5,...) contains all odd natural numbers; the even subsequence (2,4,6,...) contains all even natural numbers. More generally, for every sequence $(a_{1},a_{2},a_{3},\dots )$ one may consider its odd subsequence $(a_{1},a_{3},a_{5},\dots )$ and even subsequence $(a_{2},a_{4},a_{6},\dots ).$

## All integers in a sequence

(0,1,-1,2,-2,...)
Existence of such sequence shows that the set of all integers (including negative) is countable.
This sequence is non-monotone (that is, neither increasing nor decreasing). All integers cannot be contained in a monotone sequence, since an increasing sequence is bounded from below, and a decreasing sequence is bounded from above (think, why).
The n-th member is equal to
    ${\begin{cases}-(n-1)/2&{\text{for odd }}n,\\n/2&{\text{for even }}n.\end{cases}}$
Just for fun, these two formulas may be combined,
    ${\frac {1+(-1)^{n}(2n-1)}{4}},$
but this is not required. Two (and more) formulas are a legitimate way to define a sequence. More generally, any two sequences $(a_{1},a_{2},\dots )$ and $(b_{1},b_{2},\dots )$ may be interspersed into a single sequence $(c_{1},c_{2},\dots )=(a_{1},b_{1},a_{2},b_{2},\dots );$ here
    $c_{n}={\begin{cases}a_{(n+1)/2}&{\text{for odd }}n,\\b_{n/2}&{\text{for even }}n.\end{cases}}$
The odd subsequence $(c_{1},c_{3},c_{5},\dots )$ of the new sequence $(c_{1},c_{2},\dots )$ is equal to the first sequence $(a_{1},a_{2},\dots );$ similarly, the even subsequence $(c_{2},c_{4},c_{6},\dots )$ equals $(b_{1},b_{2},\dots ).$

## A sequence containing every natural number infinitely many times

(1,2,1,3,1,2,1,4,1,2,1,3,1,2,1,5,1,2,...)
The odd subsequence (1,1,1,...) contains only 1. The even subsequence (2,3,2,4,2,3,2,5,2,...) differs from the whole sequence only by 1 added to every member. Thus, the odd subsequence of the even subsequence contains only 2. And so on... That is, denoting n-th member by $a_{n},$ we have $a_{2n}=a_{n}+1.$
The n-th member is equal to the number q such that ${\frac {n}{2^{q-1}}}$ is an odd integer. Thus, ${\frac {n}{2^{q-1}}}=2p-1$ for some integer p. Using this p instead of q we get another sequence containing every natural number infinitely many times: (1,1,2,1,3,2,4,1,5,3,6,2,7,4,...) The odd subsequence is just (1,2,3,...). The even subsequence (1,1,2,1,3,2,4,...) is equal to the whole sequence. That is, denoting n-th member by $b_{n},$ we have $b_{2n}=b_{n}.$
In contrast, a monotone sequence cannot contain both 1 and 2 infinitely many times (think, why).

## All positive rationals in a sequence

$\textstyle {\Big1,{\frac {1}{2}},2,{\frac {1}{3}},3,1,4,{\frac {1}{4}},5,{\frac {3}{2}},6,{\frac {2}{3}},\dots {\Big )}$
The n-th member is equal to ${\frac {p}{q}}$ for positive integers p, q such that $n=(2p-1)\cdot 2^{q-1}.$ That is, $a_{(2p-1)\cdot 2^{q-1}}={\frac {p}{q}}.$ Thus, $\textstyle a_{1}=a_{1\cdot 2^{0}}=a_{(2\cdot 1-1)\cdot 2^{1-1}}={\frac {1}{1}}=1;$ $\textstyle a_{2}=a_{1\cdot 2^{1}}=a_{(2\cdot 1-1)\cdot 2^{2-1}}={\frac {1}{2}};$ $\textstyle a_{3}=a_{3\cdot 2^{0}}=a_{(2\cdot 2-1)\cdot 2^{1-1}}={\frac {2}{1}}=2;$ $\textstyle a_{4}=a_{1\cdot 2^{2}}=a_{(2\cdot 1-1)\cdot 2^{3-1}}={\frac {1}{3}};$ $\textstyle a_{5}=a_{5\cdot 2^{0}}=a_{(2\cdot 3-1)\cdot 2^{1-1}}={\frac {3}{1}}=3;$ $\textstyle a_{6}=a_{3\cdot 2^{1}}=a_{(2\cdot 2-1)\cdot 2^{2-1}}={\frac {2}{2}}=1;$ and so on. Every positive rational number ${\frac {p}{q}}$ appears in this sequence as n-th member $a_{n}$ for $n=(2p-1)\cdot 2^{q-1}.$
Existence of such sequence shows that the set of all positive rational numbers is countable.
And moreover, ${\frac {p}{q}}$ appears infinitely many times, not only for $n=(2p-1)\cdot 2^{q-1},$ but also for $n=(4p-1)\cdot 2^{2q-1},$ $n=(6p-1)\cdot 2^{3q-1}$ and so on.
Every number is an accumulation point of this sequence (that is, every neighborhood of the given number contains infinitely many members of the sequence; equivalently, the given number is the limit of some subsequence). In contrast, a monotone sequence may have only one accumulation point, namely, the limit of the whole sequence (think, why).
The function f defined by $f(q-1,p-1)+1=(2p-1)\cdot 2^{q-1}$ for integer $p,q>0,$ that is, $f(x,y)=(2y+1)\cdot 2^{x}-1$ for integer $x,y\geq 0,$ is an example of the so-called pairing function.
* Pairing function at Wikipedia.

## Factorials

* Factorial at Wikipedia.
(1,2,6,24,120,720,...)
The n-th member is equal n times the (n-1)-th member: $a_{n}=na_{n-1}$ for all $n>1.$ This is a so-called recurrence relation: each further member is defined as a function of its number and the preceding member.
* Recurrence relation at Wikipedia.
And the first member is equal to one: $a_{1}=1.$ Thus, the n-th member is the product of all natural numbers from 1 to n; it is called the factorial of n and denoted by $n!\,.$ For instance, $5!=1\cdot 2\cdot 3\cdot 4\cdot 5=120.$
Factorials are widely used. They appear in the binomial theorem, Taylor's theorem, most of well-known discrete probability distributions (binomial, negative binomial, multinomial, Poisson, hypergeometric) etc.
A wonderful approximation for large factorials is given by Stirling's formula $\textstyle n!\sim {\sqrt {2\pi n}}\,n^{n}e^{-n}.$ Its relative error $\textstyle {\big |}1-{\frac {{\sqrt {2\pi n}}\,n^{n}e^{-n}}{n!}}{\big |}$ tends to zero (as n tends to infinity), but the absolute error $|n!-{\sqrt {2\pi n}}\,n^{n}e^{-n}|$ tends to infinity.
* Stirling's approximation at Wikipedia.

## Fibonacci numbers

* Fibonacci number at Wikipedia.
(1,1,2,3,5,8,13,21,...)
The n-th member is equal the (n-1)-th member plus the (n-2)-th member: $a_{n}=a_{n-1}+a_{n-2}$ for all $n>2$ (a recurrence relation, again). And the first two members are equal to one: $a_{1}=a_{2}=1.$ Thus, $a_{3}=a_{2}+a_{1}=1+1=2;$ $a_{4}=a_{3}+a_{2}=2+1=3;$ $a_{5}=a_{4}+a_{3}=3+2=5;$ and so on.
In the 17th century Johannes Kepler observed that ratios of consecutive Fibonacci numbers $\textstyle {\big{\frac {1}{1}},{\frac {2}{1}},{\frac {3}{2}},{\frac {5}{3}},\dots {\big )}$ converge to a limit: ${\tfrac {a_{n+1}}{a_{n}}}\to \varphi$ (as $n\to \infty$) for some number $\varphi .$ If so, then necessarily ${\tfrac {a_{n+2}}{a_{n+1}}}\to \varphi ,$ therefore ${\tfrac {a_{n+1}+a_{n}}{a_{n+1}}}\to \varphi ,$ that is, $1+{\tfrac {a_{n}}{a_{n+1}}}\to \varphi ;$ taking into account that ${\tfrac {a_{n}}{a_{n+1}}}\to {\tfrac {1}{\varphi }}$ we get $1+{\tfrac {1}{\varphi }}=\varphi ,$ that is, $\varphi +1=\varphi ^{2};$ a quadratic equation on $\varphi .$ It has two roots, $(1\pm {\sqrt {5}})/2,$ one greater than 1, another smaller than 1. Clearly, the limit $\varphi$ cannot be smaller than 1 (since ${\tfrac {a_{n+1}}{a_{n}}}$ cannot); thus, this limit (if exists) must be $\varphi =(1+{\sqrt {5}})/2.$ This number is the famous "golden ratio" treated already by Euclid about 2300 years ago.
* Golden ratio at Wikipedia.
We wonder about the error of the approximate equality ${\tfrac {a_{n+1}}{a_{n}}}\approx \varphi$ (for large n), that is, $a_{n+1}\approx \varphi a_{n}.$ The absolute error being $|a_{n+1}-\varphi a_{n}|,$ we investigate the difference $a_{n+1}-\varphi a_{n};$ how does it change with n? Is $a_{n+2}-\varphi a_{n+1}$ greater or smaller (in absolute value) than $a_{n+1}-\varphi a_{n}?$
Using the recurrence relation and the property of $\varphi$ we get $a_{n+2}-\varphi a_{n+1}=a_{n+1}+a_{n}-\varphi a_{n+1}=(1-\varphi )a_{n+1}+a_{n}=-{\frac {1}{\varphi }}a_{n+1}+a_{n}=-{\frac {1}{\varphi }}(a_{n+1}-\varphi a_{n}),$ which shows that the investigated difference changes the sign and decreases in the absolute value. By induction, $a_{n+1}-\varphi a_{n}={\big-{\tfrac {1}{\varphi }}{\big )}^{n-1}(a_{2}-\varphi a_{1})$ for all n. Introducing $\psi =-{\tfrac {1}{\varphi }},$ noting that $\psi =1-\varphi$ and recalling that $a_{1}=a_{2}=1$ we get $a_{n+1}-\varphi a_{n}=\psi ^{n},$ which shows that the absolute error is decreasing and converges to 0 (since $-1<\psi <0$). Existence of the limit follows: ${\tfrac {a_{n+1}}{a_{n}}}=\varphi +{\tfrac {a_{n+1}-\varphi a_{n}}{a_{n}}}\to \varphi .$
Interestingly, the property $1+{\tfrac {1}{\varphi }}=\varphi$ of $\varphi$ leads to a similar property $1+{\tfrac {1}{\psi }}=\psi$ of $\psi ,$ as follows: $1+{\tfrac {1}{\psi }}=1-\varphi =-{\tfrac {1}{\varphi }}=\psi .$ Thus, $\psi$ is nothing but the other root of the quadratic equation: $\psi =(1-{\sqrt {5}})/2.$
The proof of the equality $a_{n+1}-\varphi a_{n}={\big-{\tfrac {1}{\varphi }}{\big )}^{n-1}(a_{2}-\varphi a_{1})$ given above does not use any other property of $\varphi ,$ and therefore it holds for $\psi$ as well: $a_{n+1}-\psi a_{n}={\big-{\tfrac {1}{\psi }}{\big )}^{n-1}(a_{2}-\psi a_{1}),$ that is (as before) $a_{n+1}-\psi a_{n}=\varphi ^{n}.$
Having explicit formulas for $a_{n+1}-\varphi a_{n}=\psi ^{n}$ and $a_{n+1}-\psi a_{n}=\varphi ^{n}$ it is easy to get an explicit formula for $a_{n}.$ We just subtract the first formula from the second and get $(\varphi -\psi )a_{n}=\varphi ^{n}-\psi ^{n},$ that is, the wonderful formula
    $a_{n}={\frac {(1+{\sqrt {5}})^{n}-(1-{\sqrt {5}})^{n}}{2^{n}{\sqrt {5}}}}.$
It follows that $a_{n}$ is the closest integer to $\varphi ^{n}/{\sqrt {5}}.$

## The decimal digits of the number $\pi$

* Pi#Irrationality and normality at Wikipedia.
(3,1,4,1,5,9,2,6,5,...) By definition, n-th member of this sequence is equal to $\lfloor 10\cdot \{10^{n-2}\pi \}\rfloor ;$ here $\lfloor x\rfloor$ is the integral part of x, and $\{x\}=x-\lfloor x\rfloor$ is the fractional part of x. Thus, the first member is $\lfloor 10\cdot \{10^{-1}\pi \}\rfloor =\lfloor 10\cdot \{0.3141\dots \}\rfloor =\lfloor 10\cdot 0.3141\dots \rfloor =\lfloor 3.141\dots \rfloor =3;$ the second member is $\lfloor 10\cdot \{10^{0}\pi \}\rfloor =\lfloor 10\cdot \{3.141\dots \}\rfloor =\lfloor 10\cdot 0.141\dots \rfloor =\lfloor 1.41\dots \rfloor =1;$ the third member is $\lfloor 10\cdot \{10^{1}\pi \}\rfloor =\lfloor 10\cdot \{31.41\dots \}\rfloor =\lfloor 10\cdot 0.41\dots \rfloor =\lfloor 4.1\dots \rfloor =4;$ and so on.
In order to calculate $\pi$ one may use the formula $\textstyle \pi =3+{\frac {4}{2\cdot 3\cdot 4}}-{\frac {4}{4\cdot 5\cdot 6}}+{\frac {4}{6\cdot 7\cdot 8}}-{\frac {4}{8\cdot 9\cdot 10}}+\dots .$ Trillions (that is, millions of millions) of decimal digits of $\pi$ are calculated using better formulas. They look as if they are random! On one hand, this is natural, since we do not know any reason for any regularity in this sequence. On the other hand, this is paradoxical, since in these digits there is not the slightest chance. The equality $\lfloor 10\cdot \{10^{1}\pi \}\rfloor =4$ is a mathematical theorem, as well as the equality $\lfloor 10\cdot \{10^{41}\pi \}\rfloor =9$, and the same can be said about $\lfloor 10\cdot \{10^{n-2}\pi \}\rfloor$ for every n. (See also Numerical calculations and rigorous mathematics.) Each of these (seemingly random) digits, being an eternal mathematical truth, could not be different. Тhis puzzling situation is vividly discussed, see Wicklin, Preuss, mathoverfow etc. "To put our ignorance in perspective, note that it is not even known that all digits appear infinitely often: perhaps Pi = 3.1415926.....01001000100001000001..." (Stan Wagon, Is Pi normal?)