A repeating decimal, also called a recurring decimal, is a number whose decimal expansion eventually becomes periodic (i.e., the same sequence of digits repeats indefinitely). The repeating portion of a decimal expansion is conventionally denoted with a vinculum so, for example,
The minimum number of digits that repeats in such a number is known as the decimal period.
Repeating decimal notation was implemented in versions of the Wolfram Language prior to 6 as PeriodicForm[RealDigits[r]] after loading the add-on package NumberTheory`ContinuedFractions`.
All rational numbers have either finite decimal expansions (e.g., )
or repeating decimals (e.g.,
). However, irrational
numbers, such as
,
neither terminate nor become periodic.
Numbers such as 0.5 are sometimes regarded as repeating decimals since .
The denominators of the first few unit fractions having nonterminating repeating decimals are 3, 6, 7, 9, 11, 12, 13, 14, 15, 17, 18, 19, 21, 22, 23, 24, 26, 27, 28, 29, ... (OEIS A085837).
For an exact rational number with a nonterminating decimal
expansion, the repeating portion can be found in the Wolfram
Language using the command RealDigits[r][[1,-1]].
The decimal period of a rational
number in lowest terms is the multiplicative
order of 10 modulo
for
, where
is obtained by removing all prime
factors 2 and 5 from its denominator. If
, the decimal
expansion terminates and its period is recorded as 0. The periods of the decimal
expansions of
for
,
2, ... are 0, 0, 1, 0, 0, 1, 6, 0, 1, 0, 2, 1, 6, 6, 1, 0, 16, 1, 18, ... (OEIS A051626), where 0 indicates a terminating decimal
expansion.
For positive integers and
, if
is relatively prime to
10,
is a nonterminating repeating decimal, and
is a terminating decimal, then
has a nonperiodic part whose length is that of
and a repeating part whose length is that of
(Wells 1986, p. 60).