Eggs in a Basket

## **Problem**

There is a basket with a certain number of eggs.

If the eggs are taken from the basket two at a time, only one egg remains.

If the eggs are taken from the basket three at a time, only one egg remains.

If the eggs are taken from the basket four at a time, only one egg remains.

If the eggs are taken from the basket five at a time, only one egg remains.

If the eggs are taken from the basket six at a time, only one egg remains.

If the eggs are taken out seven at a time, no eggs remain.

How many eggs are in the basket?

[Assume the lowest integer solution]

## **Solution**

This is an interesting Chinese remainder theorem problem that involves moduli that are not all mutually co-prime.

N

≡
1

(
mod

2
)

N

≡
1

(
mod

3
)

N

≡
1

(
mod

4
)

N

≡
1

(
mod

5
)

N

≡
1

(
mod

6
)

N

≡
0

(
mod

7
)

{\displaystyle \begin{align}
 N &\equiv 1 \pmod{2} \\
 N &\equiv 1 \pmod{3} \\
 N &\equiv 1 \pmod{4} \\
 N &\equiv 1 \pmod{5} \\
 N &\equiv 1 \pmod{6} \\
 N &\equiv 0 \pmod{7}
\end{align}}

The moduli 2, 3, 4, 6 are no co-prime, so we need to calculate the lowest common multiple:

l
c
m
(
2
,
3
,
4
,
6
# )
12

{\displaystyle lcm(2,3,4,6) = 12 }

. Since the remainder of each congruence is 1, the above system can be reduced to

N

≡
1

(
mod

12
)

N

≡
1

(
mod

5
)

N

≡
0

(
mod

7
)

{\displaystyle \begin{align}
 N &\equiv 1 \pmod{12} \\
 N &\equiv 1 \pmod{5} \\
 N &\equiv 0 \pmod{7}
\end{align}}

.
The first two congruences in the reduced system have co-prime moduli, and they also share the same remainder, so

N

≡
1

(
mod

60
)

N

≡
0

(
mod

7
)

{\displaystyle \begin{align}
 N &\equiv 1 \pmod{60} \\
 N &\equiv 0 \pmod{7}
\end{align}}

Calculate the product of the moduli

# M
60
(
7
# )
420

{\displaystyle M = 60(7) = 420 }

.

The solution of the Chinese remainder theorem prescribes that

# N

[

r
1

M
1

s
1

r
2

M
2

s
2

]

(
mod

M
)

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

.
For this problem

M
1

=

420
60

=
7
,

M
2

=

420
7

=
60

{\displaystyle
M\_1 = \frac{420}{60} = 7, \quad M\_2 = \frac{420}{7} = 60
}

# N

[

1
(
7
)

s
1

0
(
60
)

s
2

]

(
mod

420
)

{\displaystyle
N = \left[1(7)s\_1 + 0(60)s\_2 \right] \pmod{420}
}

where

7

s
1

≡
1

(
mod

60
)

60

s
2

≡
1

(
mod

7
)

{\displaystyle \begin{align}
 7s\_1 &\equiv 1 \pmod{60} \\
 60s\_2 &\equiv 1 \pmod{7}
\end{align}}

s
1

,

s
2

{\displaystyle s\_1, s\_2 }

 are the modular inverses of each respective remainder, which can be solved systematically using theEuclidean algorithm.

7
(
43
)

≡
1

(
mod

60
)

60
(
2
)

≡
1

(
mod

7
)

{\displaystyle \begin{align}
 7(43) &\equiv 1 \pmod{60} \\
 60(2) &\equiv 1 \pmod{7}
\end{align}
}

**Calculation**

# N

[

1
(
7
)
(
43
)
0
(
60
)
(
2
)

]

(
mod

420
)

{\displaystyle
N = \left[1(7)(43) + 0(60)(2) \right] \pmod{420}
}

# N
301

(
mod

420
)

{\displaystyle
N = 301 \pmod{420}
}

There are 301 eggs in the basket.

## **Historical Note**

This problem has a long history across Eurasia. Originally an Indian problem from the 7th century AD, the problem traveled along the Silk Road to Persia in the 10th century AD and eventually reaching Italy in the 13th century AD.