Sunzi Suanjing Lower Scroll 26

## **Problem**

The earliest surviving example of the Chinese Remainder Theorem is found in the *Sunzi Suanjing* (孫子算經), a text authored by the obscure mathematician named Master Sun, who was active in China sometime between  3rd - 5th centuries AD. The exact date is uncertain. The principle is believed to have been used by Chinese calendar makers as far back as 100 AD.

The original text states:

答曰：二十三。

術曰：「三、三數之，賸二」，置一百四十；「五、五數之，賸三」，置六十三；「七、七數之，賸二」，置三十。并之，得二百三十三。以二百一十減之，即得。凡三、三數之，賸一，則置七十；五，五數之，賸一，則置二十一；七、七數之，賸一，則置十五。一百六以上，以一百五減之，即得。

Answer: 23.

Method: “When counted in threes, 2 remain” set 140. “When counted in fives, 3 remain” set 63. “When counted in sevens, 2 remain” set 30. Add these numbers to get 233. Then subtract 210 to obtain the answer. When counted in threes, set 70 to get a remainder of 1. When counted in fives, set 21 to get a remainder of 1. When counted in sevens, set 15 to get a remainder of 1. While the result is greater than 106, subtract 105 to obtain the answer.

This problem is a system of indeterminate equations; hence, it has infinitely many solutions. Solve for the lowest positive integer solution.

## **Solution**

This problem is a system of indeterminate equations with infinitely many solutions.

{

N

≡
2

(
mod

3
)

N

≡
3

(
mod

5
)

N

≡
2

(
mod

7
)

{\displaystyle \begin{cases}
 N &\equiv 2 \pmod{3} \\
 N &\equiv 3 \pmod{5} \\
 N &\equiv 2 \pmod{7}
\end{cases}}

Calculate the product of the moduli

# M
3
⋅
5
⋅
# 7

{\displaystyle M = 3 \cdot 5 \cdot 7 = 105. }

The solution of the Chinese remainder theorem prescribes that

# N

[

r
1

M
1

s
1

r
2

M
2

s
2

r
3

M
3

s
3

]

(
mod

M
)
.

{\displaystyle
N = \left[r\_1 M\_1 s\_1 + r\_2 M\_2 s\_2 + r\_3 M\_3 s\_3 \right] \pmod M.
}

For this problem

M
1

=

105
3

=
35
,

M
2

=

105
5

=
21
,

M
3

=

105
7

=
15

{\displaystyle
M\_1 = \frac{105}{3} = 35, \quad M\_2 = \frac{105}{5} = 21, \quad M\_3 = \frac{105}{7} = 15
}

# N

[

2
⋅
35
⋅

s
1

3
⋅
21
⋅

s
2

2
⋅
15
⋅

s
3

]

(
mod

105
)

{\displaystyle
N = \left[2 \cdot 35 \cdot s\_1 + 3 \cdot 21 \cdot s\_2 + 2 \cdot 15 \cdot s\_3 \right] \pmod{105}
}

where

35

s
1

≡
1

(
mod

3
)

21

s
2

≡
1

(
mod

5
)

15

s
3

≡
1

(
mod

7
)

{\displaystyle \begin{align}
 35s\_1 &\equiv 1 \pmod{3} \\
 21s\_2 &\equiv 1 \pmod{5} \\
 15s\_3 &\equiv 1 \pmod{7}
\end{align}}

and

s
1

,

s
2

,

s
3

{\displaystyle s\_1, s\_2, s\_3 }

 are the modular inverses of each respective remainder, which can be solved systematically using the Euclidean algorithm. However, the numbers involved in this problem is small enough to be obtained by guessing and checking.

35
⋅
2

≡
1

(
mod

3
)

21
⋅
1

≡
1

(
mod

5
)

15
⋅
1

≡
1

(
mod

7
)

{\displaystyle \begin{align}
 35 \cdot 2 &\equiv 1 \pmod{3} \\
 21 \cdot 1 &\equiv 1 \pmod{5} \\
 15 \cdot 1 &\equiv 1 \pmod{7}
\end{align}
}

# N

[

2
⋅
35
⋅
2
3
⋅
21
⋅
1
2
⋅
15
⋅
1

]

(
mod

105
)

{\displaystyle
N = \left[2 \cdot 35 \cdot 2 + 3 \cdot 21 \cdot 1 + 2 \cdot 15 \cdot 1 \right] \pmod{105}
}

# N
233

(
mod

105
)

{\displaystyle
N = 233 \pmod{105}
}

Hence 233 is a solution. In fact, there are infinitely many solutions

# N
105
x
233

{\displaystyle N = 105x + 233 }

where

x

{\displaystyle x}

 is an integer.

Hence, the lowest positive integer solution is

233
−
2
⋅
# 105

{\displaystyle 233 - 2 \cdot 105 = 23. }

So there are 23 objects.