For a reduced fraction with , , and coprime integers, its decimal representation repeats immediately after the decimal point. The shortest repeating block has length
Here denotes multiplicative order, and denotes Euler's totient function. Changing the numerator preserves the decimal period as long as the fraction remains reduced.[ref]
For example, long division of gives the remainders , with emitted digits . Consequently
Each remainder determines both the next digit and the next remainder; returning to one restarts the same six steps.
Figure 1.
Long-division remainders explain the six-digit repeat of one seventh and the two-digit prefix of one twenty-eighth
. Details.
More generally, initialize long division with . At each step, division with remainder gives
so . Since are coprime integers, the modular inverse of shows that exactly when . To see why the digit block cannot repeat sooner than the remainders, a purely repeating decimal with a block of digits represents for an integer . A reduced fraction with that value forces . Hence the shortest digit repeat and the multiplicative order coincide.
Knowing the decimal period predicts how many digits must be computed and stored: one block determines the whole repeating decimal. It also constructs the block directly. With , the integer
is the block, padded on the left with zeros to digits. For , and , so the block is and . Reduction matters: has decimal period one, whereas .
If the reduced denominator contains prime factors two or five, ten has no multiplicative order modulo that whole denominator. Write
The decimal preperiod has exactly digits. If , the remaining repeating decimal has decimal period . For instance, gives : two prefix digits, then six repeating digits. If , the decimal representation is a terminating decimal with exactly fractional places. We use the representation ending in zeros, rather than its alternative ending in nines; for example terminates after three places.
A short derivation explains both cases. After digits, multiplying the reduced fraction by and discarding its integer part leaves a reduced fraction whose denominator is . This denominator first becomes coprime to ten at . It then equals , giving an immediate repeat when , or an integer when . The same long division argument works for positional notation in any base : for a reduced denominator coprime to , the shortest repeating block has length .
Euler's theorem Created 2026-10-03 Updated 2026-10-13
For an integer modulus and an integer with greatest common divisor , Euler's theorem, also called the Fermat-Euler theorem, states
Here Euler's totient function counts the units in the unit group . These congruence classes have modular multiplicative inverses, equivalently their representatives are coprime to . The guaranteed return to one permits exponent reduction for units.[ref]
For a prime number , , recovering Fermat's little theorem in the form when . Multiplying by and separately handling gives for every integer . For a composite number used as the integer modulus, a nonzero congruence class can be a nonunit.
Modulo twelve, the units have representatives , so Euler's totient function gives . Multiplication by five produces
Thus this permutation has two permutation cycles, each of length two. In particular , and the guaranteed return follows. The number of units need not be the length of one permutation cycle. Modulo fifteen, multiplication by seven similarly gives the two permutation cycles and , covering all eight units. The powers of seven follow the permutation cycle containing one; the other permutation cycle shows that these powers do not visit every unit.
Figure 1.
Two unit permutations: multiplication by five modulo twelve and by seven modulo fifteen
. Every arrow multiplies by the indicated unit and reduces modulo the indicated integer modulus. The permutation cycles exhaust each reduced residue system. The permutation cycle containing one records the powers of the multiplier; its length is the multiplier's multiplicative order, which can be smaller than Euler's totient function. Details.
There is a stronger obstruction for a nonunit than just an occasional failed calculation. If a positive integer divides both and , then for every , so cannot be congruent to one modulo . For example, and , rather than one. Such a base has no multiplicative order modulo that integer modulus.[ref]
For a unit modulo n and a nonnegative integer , division with remainder writes with . Euler's theorem then gives
This replaces a potentially enormous exponent by a small remainder. The exponent itself is reduced modulo Euler's totient function, while the powers are reduced modulo : these are different integer moduli.
For a worked modulo-fifteen calculation, seven is coprime to fifteen and . Therefore
Use exponentiation by squaring on the remaining exponent , reducing after each multiplication:
Thus . Modular exponentiation supplies the computation; Euler's theorem supplies the optional shortening of its exponent. Exponentiation by squaring also works for nonunit bases, without using this shortening.
The guaranteed exponent is a common return exponent and an upper bound on the shortest period; it need not be that period. The multiplicative order is the least positive return exponent for the chosen unit. The Carmichael function is the least positive return exponent that works for every unit. Their precise relation is
Either smaller return exponent can replace in exponent reduction for units. Modulo fifteen, , so gives immediately. For base four the multiplicative order is only two, smaller even than . A return at exponent eight alone does not prove that the multiplicative order is eight.[ref]
Figure 1.
Actual power periods, Carmichael function exponents and Euler return exponents
. Each row lists powers from exponent zero through eight. Highlighted first returns identify multiplicative orders; the accompanying labels distinguish a chosen base's shortest period, the common exponent for all units, and Euler's totient function. Powers of the nonunit three modulo fifteen repeat after an initial term but never return to one at a positive exponent. The final calculation compares reduction of modulo eight and modulo four. Details.
If the reduced exponent is zero, the rule gives , and still requires a unit. Applying it to the nonunit three would falsely predict ; the actual residue is six. For negative exponents, first interpret the power using a modular multiplicative inverse, as in modular exponentiation.