《孫子算經卷下》 "Sun Tzŭ's Computational Classic: Volume III"
§26. Chinese remainder theorem

This section gives an example of the Chinese remainder theorem.

Translation

Chinese source text: Version A, Version B, Version C, Version D.
Unless noted otherwise, I follow the text from Version D, 《知不足齋叢書》本.

Source text Target text Notes
今有物不知其數。三三數之賸二五五數之賸三七七數之賸二。問物幾何。 Suppose there be objects [we] know not [the] number thereof. Numbering them three [by] three [there] remain two; numbering them five [by] five [there] remain three; numbering them seven [by] seven [there] remain two. [We] ask, how many [be the] objects?
  • 數之: numbering them

    數、上聲、 Cantonese: shou2 (post-merger: sou2), Mandarin: shǔ

  • In modern notation, we have the simultaneous congruences
    \begin{aligned} x &\equiv \colr{2} \colb{\pmod{3}} \\ x &\equiv \colr{3} \colb{\pmod{5}} \\ x &\equiv \colr{2} \colb{\pmod{7}} \end{aligned}
    in x the number of objects.
答曰、二十三。 Answer saith: twenty-three.
術曰、三三數之賸二、置一百四十、五五數之賸三、置六十三、七七數之賸二、置三十。 Method saith: [for the] numbering them three [by] three [there] remaining two, put [down] one hundred [and] forty; [for the] numbering them five [by] five [there] remaining three, put [down] sixty-three; [for the] numbering them seven [by] seven [there] remaining two, put [down] thirty.
并之、得二百三十三。 Combining them, resulteth in two hundred [and] thirty-three.
以二百一十減之、即得。 Subtracting of it by two hundred [and] ten, [we] are done.
三三數之賸一、則置七十五五數之賸一、則置二十一七七數之賸一、則置十五 [For] every numbering them three [by] three [there] remaining one, put [down] seventy; numbering them five [by] five [there] remaining one, put [down] twenty-one; numbering them seven [by] seven [there] remaining one, put [down] fifteen.
一百六以上、以一百五減之、即得。 [For] one hundred [and] six [or] above, subtracting of it by one hundred [and] five, [we] are done.
  • Under modern appraisal, the text does not present the Chinese remainder theorem (or rather, an instance of its application) in a particularly satisfactory manner; the quantities \colv{70}, \colv{21}, and \colv{15} are offered up with no explanation. Neither is there any convincing argument of why those quantities should be combined in the way they are combined, nor any explanation of where the modulus 105 comes from.
  • From modern number theory, since \colb{3}, \colb{5}, and \colb{7} are pairwise coprime, the solution in x is unique modulo \colb{3 \times 5 \times 7} = 105. Seeking integers \nu_3, \nu_5, and \nu_7 such that
    \begin{aligned} \nu_3 \cdot 5 \cdot 7 &\equiv \colg{1} \colb{\pmod{3}} \\ \nu_5 \cdot 3 \cdot 7 &\equiv \colg{1} \colb{\pmod{5}} \\ \nu_7 \cdot 3 \cdot 5 &\equiv \colg{1} \colb{\pmod{7}}, \end{aligned}
    we get
    \begin{aligned} \nu_3 \cdot 5 \cdot 7 &= \colv{70} \\ \nu_5 \cdot 3 \cdot 7 &= \colv{21} \\ \nu_7 \cdot 3 \cdot 5 &= \colv{15}, \end{aligned}
    and therefore
    \begin{aligned} x &\equiv \colr{2} (\colv{70}) + \colr{3} (\colv{21}) + \colr{2} (\colv{15}) \\ &= 140 + 63 + 30 \\ &= 233 \\ &\equiv 23 \pmod{105}. \end{aligned}

Cite this page

Conway (2023). "Sun Tzŭ's Computational Classic: Volume III §26". <https://yawnoc.github.io/sun-tzu/iii/26> Accessed yyyy-mm-dd.