Skip to content
TopicTracker
From HackerNewsView original
TranslationTranslation

When will the decimals in A/B repeat?

The article explains a mathematical method for determining when the decimal representation of a fraction A/B will repeat, focusing on the relationship between the denominator's prime factors and the repeating period length.

Background

- John D. Cook is a mathematician and blogger who writes accessible posts about math, statistics, and computing for a general audience. - This post explains the mathematical rule for when the decimal expansion of a fraction A/B (in base 10) eventually repeats (as all rational numbers do), and more specifically how long that repeating block, or "period," will be. - The key result: the period of the repeating decimal for A/B is the smallest positive integer k such that 10^k ≡ 1 (mod B'), where B' is B with all factors of 2 and 5 removed. This is because 2 and 5 are the prime factors of 10, so they determine when the decimal terminates (non-repeating part) versus repeats. - This connects to modular arithmetic and the concept of the multiplicative order of 10 modulo a number — a foundational idea in number theory that also appears in cryptography and coding theory.

Related stories

  • The article revisits the topic of the period length of repeating decimals in fractions a/b, following a previous post on harmonic numbers. It explains how to determine the cycle length of decimal digits and provides code to compute it.