Repeating decimal
A repeating decimal or recurring decimal is decimal representation of a number whose digits are periodic (repeating its values at regular intervals) and the infinitely repeated portion is not zero. It can be shown that a number is rational if and only if its decimal representation is repeating or terminating (i.e. all except finitely many digits are zero). For example, the decimal representation of 1/3 becomes periodic just after the decimal point, repeating the single digit "3" forever, i.e. 0.333.... A more complicated example is 3227/555, whose decimal becomes periodic at the second digit following the decimal point and then repeats the sequence "144" forever, i.e. 5.8144144144.... At present, there is no single universally accepted notation or phrasing for repeating decimals.
The infinitely repeated digit sequence is called the repetend or reptend. If the repetend is a zero, this decimal representation is called a terminating decimal rather than a repeating decimal, since the zeros can be omitted and the decimal terminates before these zeros.^{[1]} Every terminating decimal representation can be written as a decimal fraction, a fraction whose denominator is a power of 10 (e.g. 1.585 = 1585/1000); it may also be written as a ratio of the form k/2^{n}5^{m} (e.g. 1.585 = 317/2^{3}5^{2}). However, every number with a terminating decimal representation also trivially has a second, alternative representation as a repeating decimal whose repetend is the digit 9. This is obtained by decreasing the final (rightmost) nonzero digit by one and appending a repetend of 9. Two examples of this are 1.000... = 0.999... and 1.585000... = 1.584999.... (This type of repeating decimal can be obtained by long division if one uses a modified form of the usual division algorithm.^{[2]})
Any number that cannot be expressed as a ratio of two integers is said to be irrational. Their decimal representation neither terminates nor infinitely repeats, but extends forever without repetition (see § Every rational number is either a terminating or repeating decimal). Examples of such irrational numbers are √2 and π.
Background
Notation
There are several notational conventions for representing repeating decimals. None of them are accepted universally.
Fraction  Vinculum  Dots  Parentheses  Arc  Ellipsis 

1/9  0.1  0.  0.(1)  0.111...  
1/3 = 3/9  0.3  0.  0.(3)  0.333...  
2/3 = 6/9  0.6  0.  0.(6)  0.666...  
9/11 = 81/99  0.81  0.  0.(81)  0.8181...  
7/12 = 525/900  0.583  0.58  0.58(3)  0.58333...  
1/7 = 142857/999999  0.142857  0.4285  0.(142857)  0.142857142857...  
1/81 = 12345679/999999999  0.012345679  0.1234567  0.(012345679)  0.012345679012345679...  
22/7 = 3142854/999999  3.142857  3.4285  3.(142857)  3.142857142857... 
 Vinculum: In the United States , Canada , India , France , Germany , Italy, Switzerland , the Czech Republic, Slovakia, Slovenia, and Turkey the convention is to draw a horizontal line (a vinculum) above the repetend. (See examples in table above, column Vinculum.)
 Dots: In the United Kingdom , New Zealand, Australia , India , South Korea , and China , the convention is to place dots above the outermost numerals of the repetend. (See examples in table above, column Dots.)
 Parentheses: In parts of Europe, Vietnam and Russia , the convention is to enclose the repetend in parentheses. (See examples in table above, column Parentheses.) This can cause confusion with the notation for standard uncertainty.
 Arc: In Spain and some Latin American countries, the arc notation over the repetend is also used as an alternative to the vinculum and the dots notation. (See examples in table above, column Arc.)
 Ellipsis: Informally, repeating decimals are often represented by an ellipsis (three periods, 0.333...), especially when the previous notational conventions are first taught in school. This notation introduces uncertainty as to which digits should be repeated and even whether repetition is occurring at all, since such ellipses are also employed for irrational numbers; π, for example, can be represented as 3.14159....
In English, there are various ways to read repeating decimals aloud. For example, 1.234 may be read "one point two repeating three four", "one point two repeated three four", "one point two recurring three four", "one point two repetend three four" or "one point two into infinity three four".
Decimal expansion and recurrence sequence
In order to convert a rational number represented as a fraction into decimal form, one may use long division. For example, consider the rational number 5/74:
0.0675
74 ) 5.00000
4.44
560
518
420
370
500
etc. Observe that at each step we have a remainder; the successive remainders displayed above are 56, 42, 50. When we arrive at 50 as the remainder, and bring down the "0", we find ourselves dividing 500 by 74, which is the same problem we began with. Therefore, the decimal repeats: 0.0675675675.....
Every rational number is either a terminating or repeating decimal
For any given divisor, only finitely many different remainders can occur. In the example above, the 74 possible remainders are 0, 1, 2, ..., 73. If at any point in the division the remainder is 0, the expansion terminates at that point. Then the length of the repetend, also called "period", is defined to be 0.
If 0 never occurs as a remainder, then the division process continues forever, and eventually, a remainder must occur that has occurred before. The next step in the division will yield the same new digit in the quotient, and the same new remainder, as the previous time the remainder was the same. Therefore, the following division will repeat the same results. The repeating sequence of digits is called "repetend" which has a certain length greater than 0, also called "period".^{[3]}
Every repeating or terminating decimal is a rational number
Each repeating decimal number satisfies a linear equation with integer coefficients, and its unique solution is a rational number. To illustrate the latter point, the number α = 5.8144144144... above satisfies the equation 10000α − 10α = 58144.144144... − 58.144144... = 58086, whose solution is α = 58086/9990 = 3227/555. The process of how to find these integer coefficients is described below.
Table of values

Script error: No such module "Vertical header". decimal
expansionℓ_{10} binary
expansionℓ_{2} 1/2 0.5 0 0.1 0 1/3 0.3 1 0.01 2 1/4 0.25 0 0.01 0 1/5 0.2 0 0.0011 4 1/6 0.16 1 0.001 2 1/7 0.142857 6 0.001 3 1/8 0.125 0 0.001 0 1/9 0.1 1 0.000111 6 1/10 0.1 0 0.00011 4 1/11 0.09 2 0.0001011101 10 1/12 0.083 1 0.0001 2 1/13 0.076923 6 0.000100111011 12 1/14 0.0714285 6 0.0001 3 1/15 0.06 1 0.0001 4 1/16 0.0625 0 0.0001 0 
Script error: No such module "Vertical header". decimal
expansionℓ_{10} 1/17 0.0588235294117647 16 1/18 0.05 1 1/19 0.052631578947368421 18 1/20 0.05 0 1/21 0.047619 6 1/22 0.045 2 1/23 0.0434782608695652173913 22 1/24 0.0416 1 1/25 0.04 0 1/26 0.0384615 6 1/27 0.037 3 1/28 0.03571428 6 1/29 0.0344827586206896551724137931 28 1/30 0.03 1 1/31 0.032258064516129 15 
Script error: No such module "Vertical header". decimal
expansionℓ_{10} 1/32 0.03125 0 1/33 0.03 2 1/34 0.02941176470588235 16 1/35 0.0285714 6 1/36 0.027 1 1/37 0.027 3 1/38 0.0263157894736842105 18 1/39 0.025641 6 1/40 0.025 0 1/41 0.02439 5 1/42 0.0238095 6 1/43 0.023255813953488372093 21 1/44 0.0227 2 1/45 0.02 1 1/46 0.02173913043478260869565 22 1/47 0.0212765957446808510638297872340425531914893617 46  0, 0, 1, 0, 0, 1, 6, 0, 1, 0, 2, 1, 6, 6, 1, 0, 16, 1, 18, 0, 6, 2, 22, 1, 0, 6, 3, 6, 28, 1, 15, 0, 2, 16, 6, 1, 3, 18, 6, 0, 5, 6, 21, 2, 1, 22, 46, 1, 42, 0, 16, 6, 13, 3, 2, 6, 18, 28, 58, 1, 60, 15, 6, 0, 6, 2, 33, 16, 22, 6, 35, 1, 8, 3, 1, 18, 6, 6, 13, 0, 9, 5, 41, 6, 16, 21, 28, 2, 44, 1, 6, 22, 15, 46, 18, 1, 96, 42, 2, 0... (sequence A051626 in the OEIS).
 0, 0, 2, 0, 4, 2, 3, 0, 6, 4, 10, 2, 12, 3, 4, 0, 8, 6, 18, 4, 6, 10, 11, 2, 20, 12, 18, 3, 28, 4, 5, 0, 10, 8, 12, 6, 36, 18, 12, 4, 20, 6, 14, 10, 12, 11, ... (=A007733[n], if n not a power of 2 else =0).
 0, 0, 3, 0, 0, 6, 142857, 0, 1, 0, 09, 3, 076923, 714285, 6, 0, 0588235294117647, 5, 052631578947368421, 0, 047619, 45, 0434782608695652173913, 6, 0, 384615, 037, 571428, 0344827586206896551724137931, 3, 032258064516129, 0, 03, 2941176470588235, 285714... (sequence A036275 in the OEIS).
 0, 1, 0, 6, 2, 6, 16, 18, 22, 28, 15, 3, 5, 21, 46, 13, 58, 60, 33, 35, 8, 13, 41, 44, 96, 4, 34, 53, 108, 112, 42, 130, 8, 46, 148, 75, 78, 81, 166, 43, 178, 180, 95, 192, 98, 99, 30, 222, 113, 228, 232, 7, 30, 50, 256, 262, 268, 5, 69, 28, 141, 146, 153, 155, 312, 79... (sequence A002371 in the OEIS).
 3, 11, 37, 101, 41, 7, 239, 73, 333667, 9091, 21649, 9901, 53, 909091, 31, 17, 2071723, 19, 1111111111111111111, 3541, 43, 23, 11111111111111111111111, 99990001, 21401, 859, 757, 29, 3191, 211, 2791, 353, 67, 103, 71, 999999000001, 2028119, 909090909090909091, 900900900900990990990991, 1676321, 83, 127, 173... (sequence A007138 in the OEIS).
 7, 3, 103, 53, 11, 79, 211, 41, 73, 281, 353, 37, 2393, 449, 3061, 1889, 137, 2467, 16189, 641, 3109, 4973, 11087, 1321, 101, 7151, 7669, 757, 38629, 1231, 49663, 12289, 859, 239, 27581, 9613, 18131, 13757, 33931... (sequence A054471 in the OEIS).
 ↑ Courant, R. and Robbins, H. What Is Mathematics?: An Elementary Approach to Ideas and Methods, 2nd ed. Oxford, England: Oxford University Press, 1996: p. 67.
 ↑ Beswick, Kim (2004), "Why Does 0.999... = 1?: A Perennial Question and Number Sense", Australian Mathematics Teacher 60 (4): 7–9
 ↑ For a base b and a divisor n, in terms of group theory this length divides
 [math]\displaystyle{ \operatorname{ord}_n(b) := \min\{ L \in \N \, \mid \, b^L \equiv 1 \text{ mod } n \} }[/math]
 [math]\displaystyle{ \lambda(n) := \max\{\operatorname{ord}_n(b) \, \mid \, \gcd(b,n)=1\} }[/math]
 1/7 = 0.142857, 6 repeating digits
 1/17 = 0.0588235294117647, 16 repeating digits
 1/19 = 0.052631578947368421, 18 repeating digits
 1/23 = 0.0434782608695652173913, 22 repeating digits
 1/29 = 0.0344827586206896551724137931, 28 repeating digits
 1/47 = 0.0212765957446808510638297872340425531914893617, 46 repeating digits
 1/59 = 0.0169491525423728813559322033898305084745762711864406779661, 58 repeating digits
 1/61 = 0.016393442622950819672131147540983606557377049180327868852459, 60 repeating digits
 1/97 = 0.010309278350515463917525773195876288659793814432989690721649484536082474226804123711340206185567, 96 repeating digits
 1/7 = 1 × 0.142857... = 0.142857...
 2/7 = 2 × 0.142857... = 0.285714...
 3/7 = 3 × 0.142857... = 0.428571...
 4/7 = 4 × 0.142857... = 0.571428...
 5/7 = 5 × 0.142857... = 0.714285...
 6/7 = 6 × 0.142857... = 0.857142...
 61, 131, 181, 461, 491, 541, 571, 701, 811, 821, 941, 971, 1021, 1051, 1091, 1171, 1181, 1291, 1301, 1349, 1381, 1531, 1571, 1621, 1741, 1811, 1829, 1861,... (sequence A073761 in the OEIS).
 7, 23, 47, 59, 167, 179, 263, 383, 503, 863, 887, 983, 1019, 1367, 1487, 1619, 1823, 2063... (sequence A000353 in the OEIS).
 1/3 = 0.3, which has a period (repetend length) of 1.
 1/11 = 0.09, which has a period of 2.
 1/13 = 0.076923, which has a period of 6.
 1/31 = 0.032258064516129, which has a period of 15.
 1/37 = 0.027, which has a period of 3.
 1/41 = 0.02439, which has a period of 5.
 1/43 = 0.023255813953488372093, which has a period of 21.
 1/53 = 0.0188679245283, which has a period of 13.
 1/67 = 0.014925373134328358208955223880597, which has a period of 33.
 1/71 = 0.01408450704225352112676058338028169, which has a period of 35.
 [math]\displaystyle{ \frac{10^{111}1}{11}= 909090909 }[/math]
 1/13 = 0.076923...
 10/13 = 0.769230...
 9/13 = 0.692307...
 12/13 = 0.923076...
 3/13 = 0.230769...
 4/13 = 0.307692...,
 2/13 = 0.153846...
 7/13 = 0.538461...
 5/13 = 0.384615...
 11/13 = 0.846153...
 6/13 = 0.461538...
 8/13 = 0.615384...,
 1/49 = 0.020408163265306122448979591836734693877551.
 [math]\displaystyle{ a^m \equiv 1 \pmod n }[/math]
 119 = 7 × 17
 λ(7 × 17) = LCM(λ(7), λ(17)) = LCM(6, 16) = 48,
 1/119 = 0.008403361344537815126050420168067226890756302521.
 [math]\displaystyle{ \frac{1}{p^k q^\ell r^m \cdots} }[/math]
 [math]\displaystyle{ \operatorname{LCM}(T_{p^k}, T_{q^\ell}, T_{r^m}, \ldots) }[/math]
 [math]\displaystyle{ \frac{1}{2^a 5^b p^k q^\ell \cdots}\, , }[/math]
 [math]\displaystyle{ \frac{5^{ab}}{10^a p^k q^\ell \cdots}\, , }[/math]
 [math]\displaystyle{ \frac{2^{ba}}{10^b p^k q^\ell \cdots}\, , }[/math]
 [math]\displaystyle{ \frac{1}{10^a p^k q^\ell \cdots}\, , }[/math]
 An initial transient of max(a, b) digits after the decimal point. Some or all of the digits in the transient can be zeros.
 A subsequent repetend which is the same as that for the fraction 1/p^{k} q^{ℓ} ⋯.
 a = 2, b = 0, and the other factors p^{k} q^{ℓ} ⋯ = 7
 there are 2 initial nonrepeating digits, 03; and
 there are 6 repeating digits, 571428, the same amount as 1/7 has.
[math]\displaystyle{ x }[/math] [math]\displaystyle{ = 0.333333\ldots }[/math] [math]\displaystyle{ 10x }[/math] [math]\displaystyle{ = 3.333333\ldots }[/math] (multiply each side of the above line by 10) [math]\displaystyle{ 9x }[/math] [math]\displaystyle{ = 3 }[/math] (subtract the 1st line from the 2nd) [math]\displaystyle{ x }[/math] [math]\displaystyle{ = \frac39 = \frac13 }[/math] (reduce to lowest terms) [math]\displaystyle{ x }[/math] [math]\displaystyle{ = \ \ \ \ 0.836363636\ldots }[/math] [math]\displaystyle{ 10x }[/math] [math]\displaystyle{ = \ \ \ \ 8.36363636\ldots }[/math] (move decimal to start of repetition = move by 1 place = multiply by 10) [math]\displaystyle{ 1000x }[/math] [math]\displaystyle{ = 836.36363636\ldots }[/math] (collate 2nd repetition here with 1st above = move by 2 places = multiply by 100) [math]\displaystyle{ 990x }[/math] [math]\displaystyle{ = 828 }[/math] (subtract to clear decimals) [math]\displaystyle{ x }[/math] [math]\displaystyle{ = \frac{828}{990} = \frac{18 \cdot 46}{18 \cdot 55} = \frac{46}{55} }[/math] (reduce to lowest terms)  [math]\displaystyle{ \begin{align} x &= 0.000000100000010000001\ldots \\ 10^7x &= 1.000000100000010000001\ldots \\ \left(10^71\right)x=9999999x &= 1 \\ x &= \frac{1}{10^71} = \frac{1}{9999999} \end{align} }[/math]
 [math]\displaystyle{ \begin{align} 7.48181818\ldots & = 7.3 + 0.18181818\ldots \\[8pt] & = \frac{73}{10}+\frac{18}{99} = \frac{73}{10} + \frac{9\cdot2}{9\cdot 11} = \frac{73}{10} + \frac{2}{11} \\[12pt] & = \frac{11\cdot73 + 10\cdot2}{10\cdot 11} = \frac{823}{110} \end{align} }[/math]
 [math]\displaystyle{ \begin{align} x &= 0.\overline{a_1 a_2 \cdots a_n} \\ 10^n x &= a_1 a_2 \cdots a_n.\overline{a_1 a_2 \cdots a_n} \\ \left(10^n  1\right)x = 99 \cdots 99x &= a_1 a_2 \cdots a_n \\ x &= \frac{a_1 a_2 \cdots a_n}{10^n  1} = \frac{a_1 a_2 \cdots a_n}{99 \cdots 99} \end{align} }[/math]
 0.444444... = 4/9 since the repeating block is 4 (a 1digit block),
 0.565656... = 56/99 since the repeating block is 56 (a 2digit block),
 0.012012... = 12/999 since the repeating block is 012 (a 3digit block); this further reduces to 4/333.
 0.999999... = 9/9 = 1, since the repeating block is 9 (also a 1digit block)
 0.000444... = 4/9000 since the repeating block is 4 and this block is preceded by 3 zeros,
 0.005656... = 56/9900 since the repeating block is 56 and it is preceded by 2 zeros,
 0.00012012... = 12/99900 = 1/8325 since the repeating block is 012 and it is preceded by 2 zeros.
 1.23444... = 1.23 + 0.00444... = 123/100 + 4/900 = 1107/900 + 4/900 = 1111/900
 or alternatively 1.23444... = 0.79 + 0.44444... = 79/100 + 4/9 = 711/900 + 400/900 = 1111/900
 0.3789789... = 0.3 + 0.0789789... = 3/10 + 789/9990 = 2997/9990 + 789/9990 = 3786/9990 = 631/1665
 or alternatively 0.3789789... = −0.6 + 0.9789789... = −6/10 + 978/999 = −5994/9990 + 9780/9990 = 3786/9990 = 631/1665
 1.23444... = 1234 − 123/900 = 1111/900 (denominator has one 9 and two 0s because one digit repeats and there are two nonrepeating digits after the decimal point)
 0.3789789... = 3789 − 3/9990 = 3786/9990 (denominator has three 9s and one 0 because three digits repeat and there is one nonrepeating digit after the decimal point)
 [math]\displaystyle{ 0.\overline{1} = \frac{1}{10} + \frac{1}{100} + \frac{1}{1000} + \cdots = \sum_{n=1}^\infty \frac{1}{10^n} }[/math]
 [math]\displaystyle{ \frac{a}{1r} = \frac{\frac{1}{10}}{1\frac{1}{10}} = \frac{1}{101} = \frac{1}{9} }[/math]
 [math]\displaystyle{ \begin{align} 0.\overline{142857} &= \frac{142857}{10^6} + \frac{142857}{10^{12}} + \frac{142857}{10^{18}} + \cdots = \sum_{n=1}^\infty \frac{142857}{10^{6n}} \\[6px] \implies &\quad \frac{a}{1r} = \frac{\frac{142857}{10^6}}{1\frac{1}{10^6}} = \frac{142857}{10^61} = \frac{142857}{999999} = \frac17 \end{align} }[/math]
 The period of 1/k for integer k is always ≤ k − 1.
 If p is prime, the period of 1/p divides evenly into p − 1.
 If k is composite, the period of 1/k is strictly less than k − 1.
 The period of c/k, for c coprime to k, equals the period of 1/k.
 If k = 2^{a}5^{b}n where n > 1 and n is not divisible by 2 or 5, then the length of the transient of 1/k is max(a, b), and the period equals r, where r is the smallest integer such that 10^{r} ≡ 1 (mod n).
 If p, p′, p″,... are distinct primes, then the period of 1/p p′ p″ ⋯ equals the lowest common multiple of the periods of 1/p, 1/p′, 1/p″,....
 If k and k′ have no common prime factors other than 2 or 5, then the period of 1/k k′ equals the least common multiple of the periods of 1/k and 1/k′.
 For prime p, if
 [math]\displaystyle{ \text{period}\left(\frac{1}{p}\right)= \text{period}\left(\frac{1}{p^2}\right)= \cdots = \text{period}\left(\frac{1}{p^m}\right) }[/math]
 for some m, but
 [math]\displaystyle{ \text{period}\left(\frac{1}{p^m}\right) \ne \text{period}\left(\frac {1}{p^{m+1}}\right), }[/math]
 then for c ≥ 0 we have
 [math]\displaystyle{ \text{period}\left(\frac{1}{p^{m+c}}\right) = p^c \cdot \text{period}\left(\frac{1}{p}\right). }[/math]
 If p is a proper prime ending in a 1, that is, if the repetend of 1/p is a cyclic number of length p − 1 and p = 10h + 1 for some h, then each digit 0, 1, ..., 9 appears in the repetend exactly h = p − 1/10 times.
 Any real number can be represented as an integer part followed by a radix point (the generalization of a decimal point to nondecimal systems) followed by a finite or infinite number of digits.
 If the base is an integer, a terminating sequence obviously represents a rational number.
 A rational number has a terminating sequence if all the prime factors of the denominator of the fully reduced fractional form are also factors of the base. These numbers make up a dense set in Q and R.
 If the positional numeral system is a standard one, that is it has base
 [math]\displaystyle{ b\in\Z\smallsetminus\{1,0,1\} }[/math]
 combined with a consecutive set of digits
 [math]\displaystyle{ D:=\{d_1, d_1+1, \dots, d_r\} }[/math]
 with r := b, d_{r} := d_{1} + r − 1 and 0 ∈ D, then a terminating sequence is obviously equivalent to the same sequence with nonterminating repeating part consisting of the digit 0. If the base is positive, then there exists an order homomorphism from the lexicographical order of the rightsided infinite strings over the alphabet D into some closed interval of the reals, which maps the strings 0.A_{1}A_{2}...A_{n}d_{b} and 0.A_{1}A_{2}...(A_{n}+1)d_{1} with A_{i} ∈ D and A_{n} ≠ d_{b} to the same real number – and there are no other duplicate images. In the decimal system, for example, there is 0.9 = 1.0 = 1; in the balanced ternary system there is 0.1 = 1.T = 1/2.
 A rational number has an indefinitely repeating sequence of finite length l, if the reduced fraction's denominator contains a prime factor that is not a factor of the base. If q is the maximal factor of the reduced denominator which is coprime to the base, l is the smallest exponent such that q divides b^{l} − 1. It is the multiplicative order ord_{q}(b) of the residue class b mod q which is a divisor of the Carmichael function λ(q) which in turn is smaller than q. The repeating sequence is preceded by a transient of finite length if the reduced fraction also shares a prime factor with the base. A repeating sequence
 [math]\displaystyle{ \left(0.\overline{A_1A_2\ldots A_\ell}\right)_b }[/math]
 represents the fraction
 [math]\displaystyle{ \frac{( A_1A_2\ldots A_\ell)_b}{b^l1}. }[/math]
 An irrational number has a representation of infinite length that is not, from any point, an indefinitely repeating sequence of finite length.
 [math]\displaystyle{ \frac{1}{k} = \frac{1}{b} + \frac{(bk)^1}{b^2} + \frac{(bk)^2}{b^3} + \frac{(bk)^3}{b^4} + \cdots + \frac{(bk)^{N1}}{b^N} + \cdots = \frac1b \frac1{1\frac{bk}b}. }[/math]
 1/7 = (1/10 + 5/10^{2} + 21/10^{3} + A5/10^{4} + 441/10^{5} + 1985/10^{6} + ...)_{base12}
Thereby fraction is the unit fraction 1/n and ℓ_{10} is the length of the (decimal) repetend.
The lengths ℓ_{10}(n) of the decimal repetends of 1/n, n = 1, 2, 3, ..., are:
For comparison, the lengths ℓ_{2}(n) of the binary repetends of the fractions 1/n, n = 1, 2, 3, ..., are:
The decimal repetends of 1/n, n = 1, 2, 3, ..., are:
The decimal repetend lengths of 1/p, p = 2, 3, 5, ... (nth prime), are:
The least primes p for which 1/p has decimal repetend length n, n = 1, 2, 3, ..., are:
The least primes p for which k/p has n different cycles (1 ≤ k ≤ p−1), n = 1, 2, 3, ..., are:
Citations
Fractions with prime denominators
A fraction in lowest terms with a prime denominator other than 2 or 5 (i.e. coprime to 10) always produces a repeating decimal. The length of the repetend (period of the repeating decimal segment) of 1/p is equal to the order of 10 modulo p. If 10 is a primitive root modulo p, then the repetend length is equal to p − 1; if not, then the repetend length is a factor of p − 1. This result can be deduced from Fermat's little theorem, which states that 10^{p−1} ≡ 1 (mod p).
The base10 digital root of the repetend of the reciprocal of any prime number greater than 5 is 9.^{[1]}
If the repetend length of 1/p for prime p is equal to p − 1 then the repetend, expressed as an integer, is called a cyclic number.
Cyclic numbers
Examples of fractions belonging to this group are:
The list can go on to include the fractions 1/109, 1/113, 1/131, 1/149, 1/167, 1/179, 1/181, 1/193, 1/223, 1/229, etc. (sequence A001913 in the OEIS).
Every proper multiple of a cyclic number (that is, a multiple having the same number of digits) is a rotation:
The reason for the cyclic behavior is apparent from an arithmetic exercise of long division of 1/7: the sequential remainders are the cyclic sequence {1, 3, 2, 6, 4, 5}. See also the article 142,857 for more properties of this cyclic number.
A fraction which is cyclic thus has a recurring decimal of even length that divides into two sequences in nines' complement form. For example 1/7 starts '142' and is followed by '857' while 6/7 (by rotation) starts '857' followed by its nines' complement '142'.
The rotation of the repetend of a cyclic number always happens in such a way that each successive repetend is a bigger number than the previous one. In the succession above, for instance, we see that 0.142857... < 0.285714... < 0.428571... < 0.571428... < 0.714285... < 0.857142.... This, for cyclic fractions with long repetends, allows us to easily predict what the result of multiplying the fraction by any natural number n will be, as long as the repetend is known.
A proper prime is a prime p which ends in the digit 1 in base 10 and whose reciprocal in base 10 has a repetend with length p − 1. In such primes, each digit 0, 1,..., 9 appears in the repeating sequence the same number of times as does each other digit (namely, p − 1/10 times). They are:^{[2]}^{:166}
A prime is a proper prime if and only if it is a full reptend prime and congruent to 1 mod 10.
If a prime p is both full reptend prime and safe prime, then 1/p will produce a stream of p − 1 pseudorandom digits. Those primes are
Other reciprocals of primes
Some reciprocals of primes that do not generate cyclic numbers are:
(sequence A006559 in the OEIS)
The reason is that 3 is a divisor of 9, 11 is a divisor of 99, 41 is a divisor of 99999, etc. To find the period of 1/p, we can check whether the prime p divides some number 999...999 in which the number of digits divides p − 1. Since the period is never greater than p − 1, we can obtain this by calculating 10^{p−1} − 1/p. For example, for 11 we get
and then by inspection find the repetend 09 and period of 2.
Those reciprocals of primes can be associated with several sequences of repeating decimals. For example, the multiples of 1/13 can be divided into two sets, with different repetends. The first set is:
where the repetend of each fraction is a cyclic rearrangement of 076923. The second set is:
where the repetend of each fraction is a cyclic rearrangement of 153846.
In general, the set of proper multiples of reciprocals of a prime p consists of n subsets, each with repetend length k, where nk = p − 1.
Totient rule
For an arbitrary integer n, the length L(n) of the decimal repetend of 1/n divides φ(n), where φ is the totient function. The length is equal to φ(n) if and only if 10 is a primitive root modulo n.^{[3]}
In particular, it follows that L(p) = p − 1 if and only if p is a prime and 10 is a primitive root modulo p. Then, the decimal expansions of n/p for n = 1, 2, ..., p − 1, all have period p − 1 and differ only by a cyclic permutation. Such numbers p are called full repetend primes.
Reciprocals of composite integers coprime to 10
If p is a prime other than 2 or 5, the decimal representation of the fraction 1/p^{2} repeats:
The period (repetend length) L(49) must be a factor of λ(49) = 42, where λ(n) is known as the Carmichael function. This follows from Carmichael's theorem which states that if n is a positive integer then λ(n) is the smallest integer m such that
for every integer a that is coprime to n.
The period of 1/p^{2} is usually pT_{p}, where T_{p} is the period of 1/p. There are three known primes for which this is not true, and for those the period of 1/p^{2} is the same as the period of 1/p because p^{2} divides 10^{p−1}−1. These three primes are 3, 487, and 56598313 (sequence A045616 in the OEIS).^{[4]}
Similarly, the period of 1/p^{k} is usually p^{k–1}T_{p}
If p and q are primes other than 2 or 5, the decimal representation of the fraction 1/pq repeats. An example is 1/119:
where LCM denotes the least common multiple.
The period T of 1/pq is a factor of λ(pq) and it happens to be 48 in this case:
The period T of 1/pq is LCM(T_{p}, T_{q}), where T_{p} is the period of 1/p and T_{q} is the period of 1/q.
If p, q, r, etc. are primes other than 2 or 5, and k, ℓ, m, etc. are positive integers, then
is a repeating decimal with a period of
where T_{pk}, T_{qℓ}, T_{rm},... are respectively the period of the repeating decimals 1/p^{k}, 1/q^{ℓ}, 1/r^{m},... as defined above.
Reciprocals of integers not coprime to 10
An integer that is not coprime to 10 but has a prime factor other than 2 or 5 has a reciprocal that is eventually periodic, but with a nonrepeating sequence of digits that precede the repeating part. The reciprocal can be expressed as:
where a and b are not both zero.
This fraction can also be expressed as:
if a > b, or as
if b > a, or as
if a = b.
The decimal has:
For example 1/28 = 0.03571428:
Converting repeating decimals to fractions
Given a repeating decimal, it is possible to calculate the fraction that produces it. For example:
Another example:
A shortcut
The procedure below can be applied in particular if the repetend has n digits, all of which are 0 except the final one which is 1. For instance for n = 7:
So this particular repeating decimal corresponds to the fraction 1/10^{n} − 1, where the denominator is the number written as n 9s. Knowing just that, a general repeating decimal can be expressed as a fraction without having to solve an equation. For example, one could reason:
It is possible to get a general formula expressing a repeating decimal with an ndigit period (repetend length), beginning right after the decimal point, as a fraction:
More explicitly, one gets the following cases:
If the repeating decimal is between 0 and 1, and the repeating block is n digits long, first occurring right after the decimal point, then the fraction (not necessarily reduced) will be the integer number represented by the ndigit block divided by the one represented by n 9s. For example,
If the repeating decimal is as above, except that there are k (extra) digits 0 between the decimal point and the repeating ndigit block, then one can simply add k digits 0 after the n digits 9 of the denominator (and, as before, the fraction may subsequently be simplified). For example,
Any repeating decimal not of the form described above can be written as a sum of a terminating decimal and a repeating decimal of one of the two above types (actually the first type suffices, but that could require the terminating decimal to be negative). For example,
An even faster method is to ignore the decimal point completely and go like this
It follows that any repeating decimal with period n, and k digits after the decimal point that do not belong to the repeating part, can be written as a (not necessarily reduced) fraction whose denominator is (10^{n} − 1)10^{k}.
Conversely the period of the repeating decimal of a fraction c/d will be (at most) the smallest number n such that 10^{n} − 1 is divisible by d.
For example, the fraction 2/7 has d = 7, and the smallest k that makes 10^{k} − 1 divisible by 7 is k = 6, because 999999 = 7 × 142857. The period of the fraction 2/7 is therefore 6.
In compressed form
The following picture suggests kind of compression of the above shortcut. Thereby [math]\displaystyle{ \mathbf{I} }[/math] represents the digits of the integer part of the decimal number (to the left of the decimal point), [math]\displaystyle{ \mathbf{A} }[/math] makes up the string of digits of the preperiod and [math]\displaystyle{ \#\mathbf{A} }[/math] its length, and [math]\displaystyle{ \mathbf{P} }[/math] being the string of repeated digits (the period) with length [math]\displaystyle{ \#\mathbf{P} }[/math] which is nonzero.
In the generated fraction, the digit [math]\displaystyle{ 9 }[/math] will be repeated [math]\displaystyle{ \#\mathbf{P} }[/math] times, and the digit [math]\displaystyle{ 0 }[/math] will be repeated [math]\displaystyle{ \#\mathbf{A} }[/math] times.
Note that in the absence of an integer part in the decimal, [math]\displaystyle{ \mathbf{I} }[/math] will be represented by zero, which being to the left of the other digits, will not affect the final result, and may be omitted in the calculation of the generating function.
Examples:
[math]\displaystyle{ \begin{array}{lllll} 3.254444... &=3.25\overline{4} &= \begin{Bmatrix} \mathbf{I}=3&\mathbf{A}=25&\mathbf{P}=4\\ &\#\mathbf{A}=2&\#\mathbf{P}=1 \end{Bmatrix} &=\frac{3254325}{900}&=\frac{2929}{900} \\ \\0.512512... &=0.\overline{512} &= \begin{Bmatrix} \mathbf{I}=0&\mathbf{A}=\emptyset&\mathbf{P}=512\\ &\#\mathbf{A}=0&\#\mathbf{P}=3 \end{Bmatrix} &=\frac{5120}{999}&=\frac{512}{999} \\ \\1.09191... &=1.0\overline{91} &= \begin{Bmatrix} \mathbf{I}=1&\mathbf{A}=0&\mathbf{P}=91\\ &\#\mathbf{A}=1&\#\mathbf{P}=2 \end{Bmatrix} &=\frac{109110}{990}&=\frac{1081}{990} \\ \\1.333... &=1.\overline{3} &= \begin{Bmatrix} \mathbf{I}=1&\mathbf{A}=\emptyset&\mathbf{P}=3\\ &\#\mathbf{A}=0&\#\mathbf{P}=1 \end{Bmatrix} &=\frac{131}{9}&=\frac{12}{9}&=\frac{4}{3} \\ \\0.3789789... &=0.3\overline{789} &= \begin{Bmatrix} \mathbf{I}=0&\mathbf{A}=3&\mathbf{P}=789\\ &\#\mathbf{A}=1&\#\mathbf{P}=3 \end{Bmatrix} &=\frac{37893}{9990}&=\frac{3786}{9990}&=\frac{631}{1665} \end{array} }[/math]
The symbol [math]\displaystyle{ \emptyset }[/math] in the examples above denotes the absence of digits of part [math]\displaystyle{ \mathbf{A} }[/math] in the decimal, and therefore [math]\displaystyle{ \#\mathbf{A}=0 }[/math] and a corresponding absence in the generated fraction.
Repeating decimals as infinite series
A repeating decimal can also be expressed as an infinite series. That is, a repeating decimal can be regarded as the sum of an infinite number of rational numbers. To take the simplest example,
The above series is a geometric series with the first term as 1/10 and the common factor 1/10. Because the absolute value of the common factor is less than 1, we can say that the geometric series converges and find the exact value in the form of a fraction by using the following formula where a is the first term of the series and r is the common factor.
Similarly,
Multiplication and cyclic permutation
The cyclic behavior of repeating decimals in multiplication also leads to the construction of integers which are cyclically permuted when multiplied by certain numbers. For example, 102564 × 4 = 410256. 102564 is the repetend of 4/39 and 410256 the repetend of 16/39.
Other properties of repetend lengths
Various properties of repetend lengths (periods) are given by Mitchell^{[5]} and Dickson.^{[6]}
For some other properties of repetends, see also.^{[7]}
Extension to other bases
Various features of repeating decimals extend to the representation of numbers in all other integer bases, not just base 10:
For example, in duodecimal, 1/2 = 0.6, 1/3 = 0.4, 1/4 = 0.3 and 1/6 = 0.2 all terminate; 1/5 = 0.2497 repeats with period length 4, in contrast with the equivalent decimal expansion of 0.2; 1/7 = 0.186A35 has period 6 in duodecimal, just as it does in decimal.
If b is an integer base and k is an integer, then
For example 1/7 in duodecimal:
which is 0.186A35_{base12}. 10_{base12} is 12_{base10}, 10^{2}_{base12} is 144_{base10}, 21_{base12} is 25_{base10}, A5_{base12} is 125_{base10}.
Algorithm for positive bases
For a rational 0 < p/q < 1 (and base b ∈ N_{>1}) there is the following algorithm producing the repetend together with its length:
function b_adic(b,p,q) // b ≥ 2; 0 < p < q static digits = "0123..."; // up to the digit with value b–1 begin s = ""; // the string of digits pos = 0; // all places are right to the radix point while not defined(occurs[p]) do occurs[p] = pos; // the position of the place with remainder p bp = b*p; z = floor(bp/q); // index z of digit within: 0 ≤ z ≤ b1 p = b*p − z*q; // 0 ≤ p < q if p = 0 then L = 0; if not z = 0 then s = s . substring(digits, z, 1) end if return (s); end if s = s . substring(digits, z, 1); // append the character of the digit pos += 1; end while L = pos  occurs[p]; // the length of the repetend (being < q) // mark the digits of the repetend by a vinculum: for i from occurs[p] to pos1 do substring(s, i, 1) = overline(substring(s, i, 1)); end for return (s); end function
The first highlighted line calculates the digit z.
The subsequent line calculates the new remainder p′ of the division modulo the denominator q. As a consequence of the floor function floor
we have
 [math]\displaystyle{ \frac{b p}{q}  1 \; \; \lt \; \; z = \left\lfloor \frac{b p}{q} \right\rfloor \; \; \le \; \; \frac{b p}{q} , }[/math]
thus
 [math]\displaystyle{ b p  q \lt z q \quad \implies \quad p' := b p  z q \lt q }[/math]
and
 [math]\displaystyle{ z q \le b p\quad \implies \quad 0 \le b p  z q =: p' \,. }[/math]
Because all these remainders p are nonnegative integers less than q, there can be only a finite number of them with the consequence that they must recur in the while
loop. Such a recurrence is detected by the associative array occurs
. The new digit z is formed in the yellow line, where p is the only nonconstant. The length L of the repetend equals the number of the remainders (see also section Every rational number is either a terminating or repeating decimal).
Applications to cryptography
Repeating decimals (also called decimal sequences) have found cryptographic and errorcorrection coding applications.^{[8]} In these applications repeating decimals to base 2 are generally used which gives rise to binary sequences. The maximum length binary sequence for 1/p (when 2 is a primitive root of p) is given by:^{[9]}
 [math]\displaystyle{ a(i) = 2^i \bmod p \bmod 2 }[/math]
These sequences of period p − 1 have an autocorrelation function that has a negative peak of −1 for shift of p − 1/2. The randomness of these sequences has been examined by diehard tests.^{[10]}
See also
 Decimal representation
 Full reptend prime
 Midy's theorem
 Parasitic number
 Trailing zero
 Unique prime
 0.999..., a repeating decimal equal to one
 Pigeonhole principle
References and remarks
 ↑ Gray, Alexander J. (March 2000). "Digital roots and reciprocals of primes". Mathematical Gazette 84 (499): 86. doi:10.2307/3621484. "For primes greater than 5, all the digital roots appear to have the same value, 9. We can confirm this if...".
 ↑ Dickson, L. E., History of the Theory of Numbers, Volume 1, Chelsea Publishing Co., 1952.
 ↑ William E. Heal. Some Properties of Repetends. Annals of Mathematics, Vol. 3, No. 4 (Aug., 1887), pp. 97–103
 ↑ Albert H. Beiler, Recreations in the Theory of Numbers, p. 79
 ↑ Mitchell, Douglas W., "A nonlinear random number generator with known, long cycle length", Cryptologia 17, January 1993, pp. 55–62.
 ↑ Dickson, Leonard E., History of the Theory of Numbers, Vol. I, Chelsea Publ. Co., 1952 (orig. 1918), pp. 164–173.
 ↑ Armstrong, N. J., and Armstrong, R. J., "Some properties of repetends", Mathematical Gazette 87, November 2003, pp. 437–443.
 ↑ Kak, Subhash, Chatterjee, A. "On decimal sequences". IEEE Transactions on Information Theory, vol. IT27, pp. 647–652, September 1981.
 ↑ Kak, Subhash, "Encryption and errorcorrection using dsequences". IEEE Transactios on Computers, vol. C34, pp. 803–809, 1985.
 ↑ Bellamy, J. "Randomness of D sequences via diehard testing". 2013. arXiv:1312.3618
External links
de:Rationale Zahl#Dezimalbruchentwicklung
Original source: https://en.wikipedia.org/wiki/Repeating decimal.
Read more 