Skip to main content
← Mathematics

NUMBER THEORY ⋅\cdot INTEGERS AND PROOFS

Congruences

Suppose we put 17 counters into packets of 5. Three full packets use 15 counters, and 2 remain. If we start with 22 counters, four full packets use 20, and again 2 remain. The totals are different. But if our question is only “how many remain?”, those two totals give the same answer.

Can we use that smaller piece of information without calculating a large total first? For example, can we find the last digit of 7 multiplied by itself 2026 times? We will build the method from these packets, explain exactly which calculations it allows, and then use it to find all possible answers—or prove there cannot be any.

You only need ordinary addition, subtraction and multiplication to begin. We will explain the integer notation, division with remainder, and proof tools where we use them. The pictures help us inspect examples; they do not replace the arguments about every integer.

01

What do we keep after making equal groups?

Let’s keep the 17 counters and packets of 5. Each outlined blue packet below contains five counters. The dashed gold packet contains only the two left over. It is not another complete packet of five.

5
5
5
2
17=3×5+2,22=4×5+217=3\times5+2,\qquad 22=4\times5+2

The 5 tells us the size of a full group; we call it the divisor here. The 3 or 4 counts full groups and is called the quotient. The 2 left over is the remainder. A remainder must be at least zero and smaller than the group size. If five or more counters remained, we could make another complete packet, so the grouping would not yet be finished.

We use letters so that one sentence can cover different totals. Let aa be an integer: one of …, −3,−2,−1,0,1,2,3-3, -2, -1, 0, 1, 2, 3, …, without a fractional part. We write a∈Za \in \mathbb Z to say “aa is an integer”. Let mm be our fixed positive group size, at least 2. Then qq is an integer quotient and rr is the remainder:

a=qm+r,q∈Z,0≤r<ma=qm+r,\qquad q\in\mathbb Z,\qquad 0\le r<m

The letters next to one another in qmqm mean multiplication: q×mq \times m. Negative totals cannot be pictured as physical packets of counters. A number line lets us keep the same equation: choose a multiple qmqm at or to the left of aa, then move rr units to the right. For example, −1=(−1)×5+4-1 = (-1) \times 5 + 4. We start at −5-5 and move four units right to −1-1. The quotient is −1-1, but the remainder is 4, not −1-1.

Place one integer, then keep only its remainder

The gold point is aa. Blue labels mark multiples of mm. Each small tick is one unit; the picture follows aa, so zero need not stay on screen. Change aa or mm, then use Next step. Nothing moves while you are reading.

17
5

Step 1 of 3 — First locate aa on this part of the number line.

Number line with unit ticks, selected integer and remainder distance1015172025a = 17

We chose a=17a = 17 and m=5m = 5.

02

Why there is exactly one remainder

The picture found a remainder for a few integers. Before building rules on it, we need two guarantees: every integer has such a description, and two different remainders cannot both be correct. We prove those separately.

First, find a description for every integer

If aa is nonnegative, start at aa and repeatedly subtract mm while at least mm remains. Each subtraction removes a full group. The remainder falls by at least 1 each time and never becomes negative, so this process must stop: there are only a+1a + 1 nonnegative integers from 0 to aa. If we subtracted mm exactly qq times, the final number rr satisfies a=qm+ra = qm + r and 0≤r<m0 \le r < m.

If aa is negative, write a=−na = -n with nn positive, and apply the process to nn. Suppose n=qm+rn = qm + r. When r=0r = 0, changing the sign gives a=(−q)m+0a = (-q)m + 0. When r>0r > 0, aa initially becomes −qm−r-qm - r. To make the remainder positive, subtract one more full mm from the multiple and give it back in the remainder:

a=−qm−r=(−q−1)m+(m−r)a=-qm-r=(-q-1)m+(m-r)

Expanding the right side gives −qm−m+m−r=−qm−r-qm - m + m - r = -qm - r, so the number has not changed. Since 0<r<m0 < r < m, subtracting rr from mm gives 0<m−r<m0 < m - r < m. Thus the new remainder is allowed. These two cases cover every negative integer, so existence is proved.

Next, rule out two different answers

Suppose someone gives two descriptions a=qm+ra = qm + r and a=sm+ta = sm + t, with both rr and tt between 0 and m−1m - 1. Subtract the second description from the first. The aa values cancel because they are the same integer:

0=qm+r−sm−t=m(q−s)+(r−t)m(q−s)=t−r\begin{aligned}0&=qm+r-sm-t\\&=m(q-s)+(r-t)\\m(q-s)&=t-r\end{aligned}

Because rr and tt are both in that range, their difference lies strictly between −m-m and mm. But an integer multiple of mm is either zero or has size at least mm: a nonzero integer multiplier has size at least 1. Therefore the only possible multiple here is zero. So q−s=0q - s = 0, hence q=sq = s; then t−r=0t - r = 0, hence t=rt = r. We have proved that the quotient and allowed remainder are unique.

The restriction 0≤r<m0 \le r < m matters. Without it, 17=3×5+217 = 3 \times 5 + 2 and 17=2×5+717 = 2 \times 5 + 7 would both be descriptions. The second is a correct equality, but 7 is not the allowed remainder on division by 5.

03

Give “the same remainder” a precise meaning

Return to 17 and 22. Their difference is 22−17=522 - 17 = 5, exactly one full packet. Adding or removing full packets changes the total but not the remainder. We want a notation for that precise agreement. We write a≡b(modm)a \equiv b \pmod{m}, read “aa is congruent to bb modulo mm”, to mean that aa and bb have the same remainder on division by mm. The fixed number mm is called the modulus.

17≡22(mod5)−1≡4(mod5)\begin{gathered}17\equiv22\pmod5\\-1\equiv4\pmod5\end{gathered}

All integers sharing one remainder form one remainder class. We can name that whole class using any one of its members, called a representative. For example, the class containing 2 modulo 5 contains …, −8,−3,2,7,12,17,22-8, -3, 2, 7, 12, 17, 22, … because each is 5 times an integer plus 2. Using the representative 2 does not mean the class contains only that one integer.

The ≡\equiv sign here does not mean the integers are equal, nor that they are approximately equal. It means exactly that their remainders agree for the stated modulus. The modulus cannot be omitted from the reasoning: 17 and 22 have the same remainder modulo 5, but modulo 3 their remainders are 2 and 1.

There is another description that will be easier to calculate with. The notation m∣nm \mid n means “mm divides nn”: nn equals mm times an integer. It is not a division sign. We now prove, in both directions, that having the same remainder is equivalent to the difference being a multiple of mm.

a≡b(modm)⇕m∣(a−b)⇕a−b=mk(k∈Z)\begin{gathered}a\equiv b\pmod m\\\Updownarrow\\m\mid(a-b)\\\Updownarrow\\a-b=mk\quad(k\in\mathbb Z)\end{gathered}

First suppose the remainders agree. Write a=qm+ra = qm + r and b=sm+rb = sm + r. Subtracting gives a−b=qm+r−sm−r=m(q−s)a - b = qm + r - sm - r = m(q - s). Because q−sq - s is an integer, the difference is an integer multiple of mm.

Conversely, suppose a−b=mka - b = mk for an integer kk. Write the allowed remainders separately: a=qm+r,b=sm+ta = qm + r, b = sm + t. Substitute these expressions, and move the multiple of mm to the other side:

mk=m(q−s)+(r−t)r−t=m(k−q+s)\begin{aligned}mk&=m(q-s)+(r-t)\\r-t&=m(k-q+s)\end{aligned}

Again r−tr - t lies strictly between −m-m and mm. Again it is a multiple of mm. The argument in the uniqueness proof forces it to be zero, so r=tr = t. Both directions are now proved. The double arrow means that either statement implies the other.

This also explains three small moves we will use. Every number is congruent to itself because a−a=m×0a - a = m \times 0. We may reverse a congruence because a−b=mka - b = mk gives b−a=m(−k)b - a = m(-k). We may join two congruences with the same modulus: if a−b=mka - b = mk and b−c=mhb - c = mh, adding gives a−c=m(k+h)a - c = m(k + h). Thus a≡ba \equiv b and b≡cb \equiv c imply a≡ca \equiv c, always with that same modulus.

04

Which calculations preserve the remainder?

If we know only remainders, can we still add or multiply? Let a≡b(modm)a \equiv b \pmod{m} and c≡d(modm)c \equiv d \pmod{m}. The difference description we just proved lets us write a=b+mka = b + mk and c=d+mhc = d + mh, where kk and hh are integers. These equations say exactly how much information was removed: whole multiples of mm.

Addition and subtraction

(a+c)−(b+d)=(b+mk+d+mh)−(b+d)=mk+mh=m(k+h)(a−c)−(b−d)=(b+mk−d−mh)−(b−d)=mk−mh=m(k−h)\begin{aligned}&(a+c)-(b+d)\\&=(b+mk+d+mh)-(b+d)\\&=mk+mh\\&=m(k+h)\\[6pt]&(a-c)-(b-d)\\&=(b+mk-d-mh)-(b-d)\\&=mk-mh\\&=m(k-h)\end{aligned}

The quantities k+hk + h and k−hk - h are integers. Therefore both displayed differences are multiples of mm. By our proved description, a+c≡b+d(modm)a + c \equiv b + d \pmod{m}, and a−c≡b−d(modm)a - c \equiv b - d \pmod{m}. In particular, adding the same integer to both sides is allowed: that integer is congruent to itself.

Multiplication

For multiplication, we must include every term, including the product of the two removed multiples. Expanding the brackets shows these terms; gathering the ones that contain mm shows that their sum is a multiple of mm:

ac=(b+mk)(d+mh)=bd+bmh+dmk+m2kh=bd+m(bh+dk+mkh),ac−bd=m(bh+dk+mkh).\begin{aligned}ac&=(b+mk)(d+mh)\\&=bd+bmh+dmk+m^2kh\\&=bd+m(bh+dk+mkh),\\ac-bd&=m(bh+dk+mkh).\end{aligned}

The bracket contains only sums and products of integers, so it is an integer. Hence ac≡bd(modm)ac \equiv bd \pmod{m}. This is why we may reduce the factors first. For example, modulo 5,17≡25, 17 \equiv 2 because 17=3×5+217 = 3 \times 5 + 2, and 22≡222 \equiv 2 because 22=4×5+222 = 4 \times 5 + 2. Thus 17×22≡2×2=4(mod5)17 \times 22 \equiv 2 \times 2 = 4 \pmod{5}. Checking the full product gives 374=74×5+4374 = 74 \times 5 + 4. The smaller calculation kept exactly the remainder we wanted.

Positive integer powers

The notation ana^{n}, for a positive integer nn, means nn copies of a multiplied together. If a≡ba \equiv b, the multiplication rule gives a2≡b2a^{2} \equiv b^{2}. Applying it to a2≡b2a^{2} \equiv b^{2} and a≡ba \equiv b gives a3≡b3a^{3} \equiv b^{3}. Why does this cover any positive nn, rather than only two examples? The starting case n=1n = 1 is our given congruence. Whenever the claim holds at nn, multiplying that congruence by a≡ba \equiv b proves it at n+1n + 1. Starting at 1 and taking this step repeatedly reaches every positive integer nn. This start-and-next-step argument is called induction.

a≡b(modm)⟹an≡bn(modm)n=1,2,3,…\begin{gathered}a\equiv b\pmod m\\\Longrightarrow a^n\equiv b^n\pmod m\\n=1,2,3,\ldots\end{gathered}

We have proved rules for addition, subtraction and multiplication, and therefore positive integer powers. We have not proved a rule allowing arbitrary division. It would be a mistake to add division to the list just because the other operations work.

05

Why ordinary cancellation can lose answers

Consider 2x≡2(mod6)2x \equiv 2 \pmod{6}. The ordinary equation 2x=22x = 2 has only x=1x = 1. But our new statement is different: it asks for 2x−22x - 2 to be a multiple of 6. Both x=1x = 1 and x=4x = 4 work, since 2×1−2=0=6×02 \times 1 - 2 = 0 = 6 \times 0, and 2×4−2=6=6×12 \times 4 - 2 = 6 = 6 \times 1. Yet 1 and 4 are not congruent modulo 6, because 4−1=34 - 1 = 3 is not a multiple of 6.

Can multiplication merge different remainder groups?

The first column lists every possible starting remainder xx. The middle column multiplies it by cc; the last column keeps only the remainder modulo mm. Gold rows reach the same final remainder as the chosen xx. Change cc, keeping mm fixed, to see when different rows meet.

6
2
1

In the diagram, the left column is the starting remainder and the right column is the resulting remainder. Each line performs “multiply by cc, then keep the remainder”. Gold lines end at the same right-hand point. The table below supplies the exact calculation behind each line.

Multiplication mapping with coinciding outputs highlightedStarting xRemainder001122334455
xxc×xc \times xRemainder modulo mm
02×0=02\times 0= 00
1 ← chosen2×1=22\times 1= 22
22×2=42\times 2= 44
32×3=62\times 3= 60
42×4=82\times 4= 82
52×5=102\times 5= 104

2×1=0×6+22\times 1= 0\times 6+ 2

Starting remainders with this same result: 1, 4.

In the initial table, the input remainders 1 and 4 both become 2 after multiplying by 2 modulo 6. Once those two inputs have merged, the output alone cannot tell us which one we started with. This is the information that an unjustified cancellation loses.

We can still divide a genuine equality. Write 2x−2=6k2x - 2 = 6k, where kk is an integer. Divide every term of this equality by 2: x−1=3kx - 1 = 3k. This says x≡1(mod3)x \equiv 1 \pmod{3}, not modulo 6. Reversing the steps shows that every such xx works. Thus all integer solutions are x=1+3kx = 1 + 3k: …, −5,−2,1,4,7,10-5, -2, 1, 4, 7, 10, …. The modulus has changed together with the cancelled factor.

When can we keep the old modulus, and how should we change it otherwise? To answer completely, we need a way to make the number 1—or a larger common divisor—out of integer multiples. We will build that tool next, rather than assume it.

06

Find the integer combination we need

Take positive integers AA and MM. A positive common divisor is a positive integer dividing both. There is always at least one, namely 1. There are only finitely many: if A=ghA = gh with gg and hh positive integers, then h≥1h \ge 1, so g≤Ag \le A. Thus every positive divisor lies in the finite list 1, 2, …, A. The largest is called the greatest common divisor, written gcd⁡(A,M)\gcd(A, M). We will show both how to find it and why it is an integer combination uA+vMuA + vM.

Replacing a pair without changing its common divisors

Divide AA by MM and write A=qM+rA = qM + r. If a positive integer gg divides AA and MM, write A=guA = gu and M=gvM = gv. Then r=A−qM=gu−qgv=g(u−qv)r = A - qM = gu - qgv = g(u - qv), so gg divides rr. In the other direction, if M=gvM = gv and r=gwr = gw, then A=qM+r=qgv+gw=g(qv+w)A = qM + r = qgv + gw = g(qv + w), so gg divides AA. Therefore the pair (A,M)(A, M) and the pair (M,r)(M, r) have exactly the same positive common divisors.

Repeat this replacement while the remainder is nonzero. Each new remainder is a nonnegative integer smaller than the preceding divisor, so the positive remainders cannot decrease forever. Eventually we reach a pair (d,0)(d, 0). Every positive divisor of dd divides 0 too, since 0 equals that divisor times 0. The largest common divisor of this final pair is dd itself. Because each replacement preserved all common divisors, dd is also gcd⁡(A,M)\gcd(A, M). This process is the Euclidean algorithm.

Keep track of how each remainder was made

At the start, A=1A+0MA = 1A + 0M and M=0A+1MM = 0A + 1M are already integer combinations of AA and MM. Suppose two current numbers are uA+vMuA + vM and sA+tMsA + tM. Subtracting qq times the second from the first gives (u−qs)A+(v−qt)M(u - qs)A + (v - qt)M, still with integer coefficients. Thus every new remainder is such a combination. We start with this property and preserve it at every step, so the final retained nonzero number dd also has it, even if it was one of the starting numbers:

d=gcd⁡(A,M)=uA+vM,u,v∈Zd=\gcd(A,M)=uA+vM,\qquad u,v\in\mathbb Z

This is Bézout’s identity. The coefficients uu and vv may be negative; “integer combination” allows subtraction as well as addition. We have proved its existence, rather than assuming that suitable coefficients can always be guessed.

Work the numbers: combine 7 and 12 to make 1

For 7 and 12, start by dividing the larger number by the smaller. At each following line, use the preceding divisor and remainder:

12=1×7+5,7=1×5+2,5=2×2+1,2=2×1+0.\begin{aligned}12&=1\times7+5,\\7&=1\times5+2,\\5&=2\times2+1,\\2&=2\times1+0.\end{aligned}

The last nonzero remainder is 1, so gcd⁡(7,12)=1\gcd (7, 12) = 1. To write this 1 using the original numbers, read the earlier equations backwards. First isolate 1=5−2×21 = 5 - 2 \times 2. Replace each 2 with 7−57 - 5, then each 5 with 12−712 - 7. We keep all the intermediate expansions:

1=5−2×2=5−2(7−5)=5−2×7+2×5=3×5−2×7=3(12−7)−2×7=3×12−3×7−2×7=3×12−5×7.\begin{aligned}1&=5-2\times2\\&=5-2(7-5)\\&=5-2\times7+2\times5\\&=3\times5-2\times7\\&=3(12-7)-2\times7\\&=3\times12-3\times7-2\times7\\&=3\times12-5\times7.\end{aligned}

Checking gives 36−35=136 - 35 = 1. We have not divided by 7. We have found an integer multiplier −5-5 of 7 whose result differs from 1 by a multiple of 12. That is exactly the sort of replacement for division we were looking for.

07

Cancel with the right modulus; then find inverses

We first handle the case where the multiplier cc and modulus mm have greatest common divisor 1. Such two positive integers are called coprime; this says only that their sole positive common divisor is 1. Bézout gives integers uu and vv with uc+vm=1uc + vm = 1. Suppose cA≡cB(modm)cA \equiv cB \pmod{m}. Write c(A−B)=mkc(A - B) = mk, then multiply the Bézout equation by A−BA - B:

A−B=(uc+vm)(A−B)=u c(A−B)+vm(A−B)=u mk+vm(A−B)=m(uk+v(A−B)).\begin{aligned}A-B&=(uc+vm)(A-B)\\&=u\,c(A-B)+vm(A-B)\\&=u\,mk+vm(A-B)\\&=m\bigl(uk+v(A-B)\bigr).\end{aligned}

The bracket is an integer, so mm divides A−BA - B. Hence A≡B(modm)A \equiv B \pmod{m}. We chose the Bézout equation because its left side can become A−BA - B, while its right side uses the known multiple c(A−B)c(A - B). This proves cancellation when the multiplier and modulus are coprime.

What changes when there is a common divisor?

Let d=gcd⁡(c,m)d = \gcd(c, m), with cc positive. Divide both by dd and call the results c′=c/dc' = c/d and m′=m/dm' = m/d. These are integers. They are coprime: if a positive hh divided both, then dhdh would divide both cc and mm; since dd is the greatest common divisor, dh≤ddh \le d, and division by the positive dd gives h≤1h \le 1. Thus hh can only be 1.

d=gcd⁡(c,m)cA≡cB(modm)⇕A≡B(modm/d)\begin{gathered}d=\gcd(c,m)\\cA\equiv cB\pmod m\\\Updownarrow\\A\equiv B\pmod{m/d}\end{gathered}

To prove the forward direction, write c(A−B)=mkc(A - B) = mk and divide this equality by dd. It becomes c′(A−B)=m′kc'(A - B) = m'k. Since c′c' and m′m' are coprime, the cancellation argument just proved gives m′∣(A−B)m' \mid (A - B). Conversely, if A−B=m′jA - B = m'j for an integer jj, multiply by c=dc′c = dc': c(A−B)=dc′m′j=mc′jc(A - B) = dc'm'j = mc'j. This is a multiple of mm, so the original congruence follows. Both directions hold.

There is one boundary case to explain. If m/d=1m/d = 1, division by 1 always has remainder zero: n=n×1+0n = n \times 1 + 0 for every integer nn. Thus all integers are congruent modulo 1, and the reduced statement imposes no restriction. The proof still works, since 1 divides every integer. We began with m≥2m \ge 2, but cancellation can lead to this case.

Undo multiplication with another multiplication

In ordinary arithmetic, multiplying by 1/c1/c undoes multiplying by cc. Here we want an integer uu with cu≡1(modm)cu \equiv 1 \pmod{m}. Such a uu is called a multiplicative inverse of cc modulo mm. It is an integer remainder-class inverse, not the ordinary fraction 1/c1/c. If cx≡bcx \equiv b, multiplying by uu gives ucx≡ubucx \equiv ub; since uc≡1uc \equiv 1, another use of the multiplication rule gives x≡ubx \equiv ub.

An inverse exists exactly when gcd⁡(c,m)=1\gcd (c, m) = 1. If the gcd⁡\gcd is 1, Bézout gives uc+vm=1uc + vm = 1, so uc−1=−vmuc - 1 = -vm, proving uc≡1uc \equiv 1. Conversely, if uc≡1uc \equiv 1, then uc−1=mkuc - 1 = mk, so 1=uc−mk1 = uc - mk. Every positive common divisor of cc and mm must divide this combination, hence must divide 1. If 1=gh1 = gh with gg and hh positive integers, h≥1h \ge 1 forces g≤1g \le 1; hence the only positive divisor of 1 is 1. So the gcd⁡\gcd is 1. That proves both the existence condition and its necessity.

Our worked identity 1=3×12−5×71 = 3 \times 12 - 5 \times 7 says that −5-5 is an inverse of 7 modulo 12. Adding 12 gives the representative 7. Check it: 7×7=49=4×12+17 \times 7 = 49 = 4 \times 12 + 1. An inverse is not a unique integer—adding a multiple of 12 keeps the property—but it is a unique remainder modulo 12. Indeed, if cu≡cv≡1cu \equiv cv \equiv 1 and gcd⁡(c,m)=1\gcd (c, m) = 1, the proved cancellation gives u≡v(modm)u \equiv v \pmod{m}.

08

Find every solution of a linear congruence

We can now solve ax≡b(modm)ax \equiv b \pmod{m}, where aa is a positive integer, bb is any integer, m≥2m \ge 2, and xx is the unknown integer. “Linear” means xx appears multiplied by aa, rather than squared or raised to another power. We need to answer three questions: does any solution exist, how do we get one, and how do we know we have all of them?

First decide whether a solution is possible

Put d=gcd⁡(a,m)d = \gcd(a, m). If xx is a solution, there is an integer kk with ax−b=mkax - b = mk. Move terms to get b=ax−mkb = ax - mk. Since a=d(a/d)a = d(a/d) and m=d(m/d)m = d(m/d), this becomes b=d((a/d)x−(m/d)k)b = d((a/d)x - (m/d)k). Everything in the bracket is an integer, so dd must divide bb. For example, 6x≡4(mod9)6x \equiv 4 \pmod{9} is impossible: every 6x−9k6x - 9k is a multiple of 3, but 4=1×3+14 = 1 \times 3 + 1 is not.

Now suppose dd does divide bb, so b=dhb = dh with integer hh. Bézout gives ua+vm=dua + vm = d. Multiply that whole equality by hh: a(uh)+m(vh)=dh=ba(uh) + m(vh) = dh = b. Rearranging gives a(uh)−b=−m(vh)a(uh) - b = -m(vh). Thus x0=uhx_{0} = uh is a solution, because its difference from bb after multiplying by aa is a multiple of mm. We have proved both directions of the existence criterion:

ax≡b(modm)has an integer solution⇕gcd⁡(a,m)∣b\begin{gathered}ax\equiv b\pmod m\\\text{has an integer solution}\\\Updownarrow\\\gcd(a,m)\mid b\end{gathered}

Then find every solution, without losing or adding any

Suppose x0x_{0} is one solution and xx is any other solution. Subtract ax0≡bax_{0} \equiv b from ax≡bax \equiv b. The subtraction rule gives a(x−x0)≡0(modm)a(x - x_{0}) \equiv 0 \pmod{m}. Apply the corrected cancellation with d=gcd⁡(a,m)d = \gcd (a, m): x−x0≡0(modm/d)x - x_{0} \equiv 0 \pmod{m/d}. This means x−x0=(m/d)tx - x_{0} = (m/d)t for an integer tt. Therefore every solution must have the following form:

x=x0+mdt,t∈Zx=x_0+\frac{m}{d}t,\qquad t\in\mathbb Z

We still must check that every integer of this form really works. Substitute it: ax−b=a(x0+(m/d)t)−b=(ax0−b)+m(a/d)tax - b = a(x_{0} + (m/d)t) - b = (ax_{0} - b) + m(a/d)t. The first term is a multiple of mm because x0x_{0} is a solution; the second is a multiple because a/da/d and tt are integers. Their sum is a multiple of mm. So this formula gives all solutions and only solutions.

Why there are dd different answer classes modulo mm

The integer solutions are infinite, but their remainders modulo mm are not. In the formula above, use t=0,1t = 0, 1, …, d−1d - 1. These dd answers represent distinct remainders. To see this, if the answers for t=it = i and t=jt = j were congruent modulo mm, their difference (m/d)(i−j)(m/d)(i - j) would equal mkmk. Dividing the equality by the positive m/dm/d gives i−j=dki - j = dk. But −d<i−j<d-d < i - j < d, so the uniqueness argument forces i=ji = j.

These classes also include every other integer tt. Divide tt by dd, writing t=dq+jt = dq + j with 0≤j<d0 \le j < d; when d=1d = 1, the remainder is 0. Then x0+(m/d)t=x0+(m/d)j+mqx_{0} + (m/d)t = x_{0} + (m/d)j + mq. The final term mqmq does not change the remainder modulo mm, so the answer is in the class already represented by jj. There are exactly dd classes whenever solutions exist.

A complete example: 4x≡2(mod6)4x \equiv 2 \pmod{6}

The divisions 6=1×4+26 = 1 \times 4 + 2 and 4=2×2+04 = 2 \times 2 + 0 give d=2d = 2. Since 2 divides the right side 2, solutions exist. Back-substitution gives 2=6−4=(−1)×4+1×62 = 6 - 4 = (-1) \times 4 + 1 \times 6. Here h=b/d=2/2=1h = b/d = 2/2 = 1, so x0=(−1)×1=−1x_{0} = (-1) \times 1 = -1 is one solution. The spacing is m/d=6/2=3m/d = 6/2 = 3, hence every solution is x=−1+3tx = -1 + 3t.

We may start the same list at 2, because −1+3t=2+3(t−1)-1 + 3t = 2 + 3(t - 1), and t−1t - 1 still runs through all integers. Writing x=2+3kx = 2 + 3k makes the two representatives modulo 6 easy to read: 2 and 5. Direct substitution checks the whole family, not just those two numbers:

4(2+3k)−2=8+12k−2=6+12k=6(1+2k)\begin{aligned}4(2+3k)-2&=8+12k-2\\&=6+12k\\&=6(1+2k)\end{aligned}

Every integer kk makes this a multiple of 6. Conversely, the argument above proved every solution has this form. This is the two-way check a complete solution needs.

Check the candidates, then explain the whole answer

We seek integer xx with ax≡b(modm)ax \equiv b \pmod{m}. A candidate works exactly when ax−bax - b is a multiple of mm. Next step checks the next starting remainder; Reset restores 4x≡2(mod6)4x \equiv 2 \pmod{6}. The formula after the table uses the proof above, rather than guessing a pattern from the rows.

4
2
6
4x≡2(mod6)4x\equiv 2\pmod{6}

x=0:4×0−(2)=−2=(−1)×6+4x = 0: 4\times 0- (2) = -2= ( -1) \times 6+ 4

The remainder is not zero: this candidate does not work.

xxax−bax - bDivisible by mm?
0-2No
1—Not checked yet
2—Not checked yet
3—Not checked yet
4—Not checked yet
5—Not checked yet

Here is the Euclidean calculation for the chosen aa and mm. A possible first line with quotient zero just swaps the smaller and larger number. The final nonzero number retained before the zero remainder is dd; it may be one of the starting numbers when a division is exact. The following integer coefficients certify that dd is a combination of aa and mm.

4=0×4= 0\times 6+46+ 4

6=1×6= 1\times 4+24+ 2

4=2×4= 2\times 2+02+ 0

d=2=(−1)×4+(1)×6d = 2= (-1) \times 4+ ( 1) \times 6

Because b/d=2/2=1b/d = 2/2 = 1, multiply the displayed coefficient of a by this number. This gives one solution x0=(−1)×(1)=−1x_{0} = (-1) \times (1) = -1. The spacing is m/d=6/2=3m/d = 6/2 = 3. Replacing x0x_{0} by its remainder 2 at this spacing describes the same integers.

x=2+3t,t∈Zx=2+3t,\qquad t\in\mathbb Z

Representatives modulo the original mm: 2, 5.

The table only checks starting remainders 0 through m−1m - 1, but that is enough after our proof: any integer xx can be written x=mq+rx = mq + r, and ax−b=m(aq)+ar−bax - b = m(aq) + ar - b. The two candidates xx and rr therefore either both work or both fail. Here a finite table covers all cases for a reason; it is not an unproved guess about an infinite list.

09

Large powers and decimal digits

Let’s return to the large multiplication in the introduction. A nonnegative decimal integer NN has a last digit rr between 0 and 9. The other digits count complete tens, so N=10q+rN = 10q + r. Thus its last digit is exactly its remainder modulo 10. We need the remainder of 720267^{2026}, not its enormous full value.

Keep the last digit after each multiplication by 7

The first row is the number 7 itself. Next step multiplies the previous remainder by 7, then removes complete tens. Earlier rows stay visible. This small table suggests a cycle; the argument below proves that the cycle continues.

Exponent 1: 1×7=7=1\times 7 = 7= 0×10+70\times 10 + 7

Before choosing any factor, we start the multiplication with 1; 1×71 \times 7 gives the first factor.

Exponent nnRemainder of 7n7^{n} modulo 10
17
71≡7(mod10)72=49=4×10+9≡9(mod10)73≡9×7=63=6×10+3≡3(mod10)74≡3×7=21=2×10+1≡1(mod10)\begin{aligned}7^1&\equiv7\pmod{10}\\7^2&=49=4\times10+9\\&\equiv9\pmod{10}\\7^3&\equiv9\times7\\&=63=6\times10+3\\&\equiv3\pmod{10}\\7^4&\equiv3\times7\\&=21=2\times10+1\\&\equiv1\pmod{10}\end{aligned}

Four rows alone would not prove that the pattern always repeats. The reason it repeats is the multiplication rule: multiplying any power 7n7^{n} by 747^{4} multiplies its remainder by 1, so 7n+4≡7n(mod10)7^{n+4} \equiv 7^{n} \pmod{10}. The identity 7n+4=7n×747^{n+4} = 7^{n} \times 7^{4} comes from putting together nn factors of 7 and four more factors.

Now divide the number of factors by four: 2026=4×506+22026 = 4 \times 506 + 2. We can arrange the 2026 factors into 506 blocks of four and two remaining factors. Each block of four has remainder 1, and the last two factors have remainder 9. Therefore:

72026=(74)506×72≡1506×9=9(mod10)\begin{aligned}7^{2026}&=(7^4)^{506}\times7^2\\&\equiv1^{506}\times9\\&=9\pmod{10}\end{aligned}

The last digit is 9. Notice that we reduced the exponent using a proved cycle length, 4, not by replacing 2026 with its remainder modulo 10. The modulus for the values and the length of a repeating pattern are different numbers.

Why the digit-sum test for divisibility by 9 works

A four-digit number with digits aa, bb, cc and dd means N=1000a+100b+10c+dN = 1000a + 100b + 10c + d. This is the meaning of decimal place value: aa counts thousands, bb hundreds, cc tens, and dd units. Since 10=1×9+110 = 1 \times 9 + 1, we have 10≡1(mod9)10 \equiv 1 \pmod{9}. The power rule gives 100=102≡12=1100 = 10^{2} \equiv 1^{2} = 1 and 1000=103≡13=11000 = 10^{3} \equiv 1^{3} = 1. The multiplication and addition rules now give:

N=1000a+100b+10c+d≡a+b+c+d(mod9)\begin{aligned}N&=1000a+100b+10c+d\\&\equiv a+b+c+d\pmod9\end{aligned}

For a number with more or fewer digits, each additional place has weight 10 to a positive integer power, and that weight again has remainder 1. The units place already has weight 1. Repeated addition therefore proves the same conclusion for any finite number of digits. A number is divisible by 9 exactly when its remainder is zero, so it is divisible by 9 exactly when its digit sum is divisible by 9.

For 2349, the digit sum is 2+3+4+9=18=2×92 + 3 + 4 + 9 = 18 = 2 \times 9, so its remainder is zero; direct division confirms 2349=261×92349 = 261 \times 9. For 2026, the sum is 2+0+2+6=10=1×9+12 + 0 + 2 + 6 = 10 = 1 \times 9 + 1, so its remainder is 1; indeed 2026=225×9+12026 = 225 \times 9 + 1. The rule now has a reason, and it tells us the remainder as well as answering yes or no.

10

Use all remainder cases to prove impossibility

Congruences can also show that a proposed integer equation has no answer. Consider x2=4y+2x^{2} = 4y + 2 with integer xx and yy. Instead of trying more and more values, ask what remainder each side could have modulo 4. Every integer xx has exactly one remainder among 0, 1, 2 and 3. If x≡r(mod4)x \equiv r \pmod{4}, the proved multiplication rule gives x2≡r2x^{2} \equiv r^{2}. We can therefore cover every integer by these four cases:

Remainder rr of xxSquare and division by 4Remainder of x2x^{2}
002=0=0×4+00^2 = 0 = 0 \times 4 + 00
112=1=0×4+11^2 = 1 = 0 \times 4 + 11
222=4=1×4+02^2 = 4 = 1 \times 4 + 00
332=9=2×4+13^2 = 9 = 2 \times 4 + 11

Thus an integer square has remainder 0 or 1 modulo 4, never 2. The right side 4y+24y + 2 always has remainder 2, including when yy is negative, because yy is an integer quotient and 0≤2<40 \le 2 < 4. Equal integers must have the same unique remainder. Our two sides cannot, so no integer pair (x,y)(x, y) satisfies the equation.

Passing a remainder check does not prove a solution exists. For example, 17 has remainder 1 modulo 4, which is allowed for a square. Yet x2=17x^{2} = 17 has no integer solution: 42=16<17<25=524^{2} = 16 < 17 < 25 = 5^{2}. Squaring nonnegative integers increases strictly, because (n+1)2−n2=n2+2n+1−n2=2n+1>0(n + 1)^{2} - n^{2} = n^{2} + 2n + 1 - n^{2} = 2n + 1 > 0. So no nonnegative integer can have square 17, and a negative integer has the same square as its positive opposite. A congruence can rule out an answer; when it does not, we may still need more reasoning.

11

Try the reasoning yourself, then check every step

Try writing an equation or an integer multiple for each answer before opening its explanation. A correct final remainder is useful, but the written reason is what lets someone else check the argument.

1. What is the allowed remainder of −23-23 on division by 7?

We need a multiple of 7 at or to the left of −23-23. Since (−3)×7=−21(-3) \times 7 = -21 is to its right, use (−4)×7=−28(-4) \times 7 = -28. The distance to −23-23 is −23−(−28)=5-23 - (-28) = 5. Thus −23=(−4)×7+5-23 = (-4) \times 7 + 5, with 0≤5<70 \le 5 < 7. The quotient is −4-4 and the remainder is 5, so −23≡5(mod7)-23 \equiv 5 \pmod{7}.

2. Find the remainder of 38×4738 \times 47 modulo 5 without first finding the full product.

Since 38=7×5+338 = 7 \times 5 + 3 and 47=9×5+247 = 9 \times 5 + 2, their remainders are 3 and 2. The proved multiplication rule gives 38×47≡3×2=6(mod5)38 \times 47 \equiv 3 \times 2 = 6 \pmod{5}. We must reduce once more, because 6 is not an allowed remainder: 6=1×5+16 = 1 \times 5 + 1. The final remainder is 1. As a check, the full product is 1786=357×5+11786 = 357 \times 5 + 1.

3. Solve 6x≡3(mod9)6x \equiv 3 \pmod{9}, giving all integers and all remainder classes modulo 9.

The divisions 9=1×6+39 = 1 \times 6 + 3 and 6=2×36 = 2 \times 3 show the gcd⁡\gcd is 3, and 3 divides the right side. Write 6x−3=9k6x - 3 = 9k and divide the equality by 3: 2x−1=3k2x - 1 = 3k. Thus 2x≡1(mod3)2x \equiv 1 \pmod{3}. Since 2×2=4=1×3+12 \times 2 = 4 = 1 \times 3 + 1, multiplying by 2 gives x≡2(mod3)x \equiv 2 \pmod{3}. Hence x=2+3tx = 2 + 3t for integer tt. Modulo 9 the three representatives are 2, 5 and 8, using t=0,1,2t = 0, 1, 2. Substituting the whole family gives 6(2+3t)−3=12+18t−3=9(1+2t)6(2 + 3t) - 3 = 12 + 18t - 3 = 9(1 + 2t), a multiple of 9. The earlier cancellation proves every solution is in this family.

4. Why does changing the right side to 4 make 6x≡4(mod9)6x \equiv 4 \pmod{9} impossible?

If a solution existed, 6x−4=9k6x - 4 = 9k for integers xx, kk. Move 4 and 9k9k to get 4=6x−9k=3(2x−3k)4 = 6x - 9k = 3(2x - 3k). This would make 4 a multiple of 3. But 4=1×3+14 = 1 \times 3 + 1 has remainder 1, not zero. The unique remainder cannot be both 0 and 1, so the supposed solution cannot exist.

5. Find an inverse of 3 modulo 7, then solve 3x≡4(mod7)3x \equiv 4 \pmod{7}.

From 7=2×3+17 = 2 \times 3 + 1 we get 1=7−2×31 = 7 - 2 \times 3. Thus −2-2 is an inverse of 3 modulo 7. Its nonnegative representative is 5 because −2=(−1)×7+5-2 = (-1) \times 7 + 5. Check: 3×5=15=2×7+13 \times 5 = 15 = 2 \times 7 + 1. Multiply 3x≡43x \equiv 4 by 5: 15x≡20(mod7)15x \equiv 20 \pmod{7}. Since 15≡115 \equiv 1 and 20=2×7+620 = 2 \times 7 + 6, this becomes x≡6(mod7)x \equiv 6 \pmod{7}. All solutions are x=6+7tx = 6 + 7t. Substitution gives 3(6+7t)−4=14+21t=7(2+3t)3(6 + 7t) - 4 = 14 + 21t = 7(2 + 3t), so all work; cancellation with gcd⁡(3,7)=1\gcd (3, 7) = 1 shows there are no others.

6. What is the last digit of 3153^{15}? Explain why the cycle you use continues.

The first four remainders modulo 10 are 3, 9, 7 and 1: 32=93^{2} = 9; 33=27=2×10+73^{3} = 27 = 2 \times 10 + 7; 34=81=8×10+13^{4} = 81 = 8 \times 10 + 1. Multiplying any power by 343^{4} therefore multiplies its remainder by 1, so the four-step repetition is proved. Now 15=4×3+315 = 4 \times 3 + 3, giving 315=(34)3×33≡13×7=7(mod10)3^{15} = (3^{4})^{3} \times 3^{3} \equiv 1^{3} \times 7 = 7 \pmod{10}. The last digit is 7.

7. Prove that x2+y2=4z+3x^{2} + y^{2} = 4z + 3 has no integer solutions.

Each integer square has remainder 0 or 1 modulo 4, as proved by all four cases in the preceding section. The two squares therefore give the four possible remainder sums 0+0=0,0+1=1,1+0=10 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1 and 1+1=21 + 1 = 2. None has remainder 3. But 4z+34z + 3 always has remainder 3 because zz is an integer and 0≤3<40 \le 3 < 4. Equal integers must have equal remainders, so the equation is impossible for every integer triple (x,y,z)(x, y, z). This includes negative integers because the remainder proof included them.

We began with two counters left after making packets. We can now explain why keeping a remainder is legitimate, why some cancellations lose information, how to recover every solution of a linear congruence, and how a short complete list of remainders can prove that an integer equation is impossible. In the Diophantine equations lesson, we keep the integers that a congruence hides: ax≡b(modm)ax \equiv b \pmod{m} becomes the genuine equation ax−mk=bax - mk = b with two integer unknowns xx and kk.