Modular Arithmetic
- 48Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
State Bézout’s identity for integers a and b.
48 questions
- 1
State Bézout’s identity for integers a and b.
Model answer
There exist integers s and t such that gcd(a,b)=as+bt.
Explanation
Bézout’s identity expresses the greatest common divisor as an integer linear combination of the two integers.
- 2
What algorithm can efficiently find the coefficients in Bézout’s identity?
Model answer
The extended Euclidean algorithm, also called the pulverizer, efficiently computes the coefficients.
Explanation
The extended Euclidean algorithm finds integers s and t for which gcd(a,b)=as+bt.
- 3
When can an integer be written as an integer linear combination of a and b?
Model answer
An integer can be written as an integer linear combination of a and b if and only if it is divisible by gcd(a,b).
Explanation
The integer linear combinations of a and b are exactly the multiples of their greatest common divisor.
- 4
What does it mean for two integers to be congruent modulo n?
Model answer
Integers a and b are congruent modulo n if and only if n divides a−b.
Explanation
Congruence modulo n means the difference between the integers is a multiple of n.
- 5
How does modular arithmetic simplify everyday calculations involving parity, last digits, or time?
Model answer
It focuses on remainders and ignores full multiples of the modulus; for example, parity uses remainders modulo 2, and last digits use remainders modulo 10.
Explanation
The same principle applies to clocks and weekdays: full cycles can be ignored, leaving only the remainder after division by the cycle length.
- 6
What is the division theorem for an integer n and a positive integer d?
Model answer
There is a unique pair of integers q and r such that n=qd+r and 0≤r<d.
Explanation
The theorem guarantees both the existence and uniqueness of a quotient and a nonnegative remainder in the specified range.
- 7
In the division theorem, what do q and r represent?
Model answer
q is the quotient and r is the remainder when n is divided by d.
Explanation
The division theorem writes the dividend as the divisor times the quotient plus the remainder.
- 8
How can the quotient and remainder be denoted using the notation described in the lecture?
Model answer
The quotient can be written as div(n,d) or ndivd, and the remainder as rem(n,d) or nremd.
Explanation
The lecture uses both function-style and infix notations for quotient and remainder.
- 9
How are congruence classes modulo n related to remainders?
Model answer
Every integer is congruent modulo n to its remainder, so the possible classes are represented by 0,1,…,n−1.
Explanation
Each integer belongs to the class represented by the remainder obtained when it is divided by n.
- 10
What does the congruence class of 0 modulo 5 contain?
Model answer
It contains all integers congruent to 0 modulo 5, such as 0, 5, −5, 10, and −10.
Explanation
These are precisely the multiples of 5.
- 11
Which congruence class modulo 5 contains −9, and how can you determine it?
Model answer
It is the class represented by 1, because −9 has remainder 1 when divided by 5 using a nonnegative remainder.
Explanation
The class of an integer is determined by its remainder modulo the modulus.
- 12
What does it mean for the residue classes modulo n to form a partition of the integers?
Model answer
Every integer belongs to exactly one of the classes represented by 0 through n−1.
Explanation
The classes are disjoint and together contain all integers, because each integer has a unique remainder.
- 13
State the relationship between congruence modulo n and equality of remainders.
Model answer
a is congruent to b modulo n if and only if a and b have the same remainder when divided by n.
Explanation
Equal remainders imply their difference is divisible by n; conversely, if n divides their difference, the division theorem gives them the same remainder.
- 14
Why does having equal remainders imply that two integers are congruent modulo n?
Model answer
Writing a=qn+r and b=q′n+r gives a−b=n(q−q′), so n divides their difference.
Explanation
The shared remainder cancels when the two division-theorem expressions are subtracted.
- 15
Why does congruence modulo n imply equal remainders?
Model answer
If a=b+kn and b=q′n+r, then a=(q′+k)n+r, so both integers have remainder r.
Explanation
The division theorem’s uniqueness guarantees that the remainder in these expressions is the remainder for each integer.
- 16
Give examples of two integers that are congruent modulo 5, and one pair that is not.
Model answer
17 is congruent to 12 and to 32 modulo 5, but it is not congruent to 33 modulo 5.
Explanation
The differences 17−12=5 and 17−32=−15 are multiples of 5, whereas 17−33=−16 is not.
- 17
What convention for remainders is used in the lecture, and why should programmers be cautious?
Model answer
Remainders are taken to be nonnegative; programming languages may use different remainder or modulo conventions, especially for negative inputs.
Explanation
The behavior of a programming-language operator can differ from the mathematical convention, so its definition should be checked.
- 18
How do the statements a≡b(modn) and a=bremn differ?
Model answer
The first says that a and b are congruent; the second says that a equals the particular remainder of b modulo n.
Explanation
Congruence is a relation between two integers, while remainder notation identifies one value. The lecture recommends keeping these meanings distinct in notation.
- 19
If a is congruent to b modulo n, what can be said about adding the same integer c to both?
Model answer
a+c is congruent to b+c modulo n.
Explanation
Adding the same value leaves the difference unchanged: (a+c)−(b+c)=a−b.
- 20
If a is congruent to b modulo n, what can be said about subtracting c from both?
Model answer
a−c is congruent to b−c modulo n.
Explanation
The difference between the resulting expressions is still a−b, which is divisible by n.
- 21
If a is congruent to b modulo n, what can be said about c−a and c−b?
Model answer
c−a is congruent to c−b modulo n.
Explanation
Their difference is (c−a)−(c−b)=b−a, a multiple of n.
- 22
If a is congruent to b modulo n, what can be said about multiplying both by c?
Model answer
ac is congruent to bc modulo n.
Explanation
The difference ac−bc=c(a−b) remains divisible by n.
- 23
How can congruent values be used to simplify a modular calculation?
Model answer
An intermediate value can be replaced by any congruent value that is easier to work with, without changing the final congruence.
Explanation
Addition, subtraction, and multiplication preserve congruence, allowing calculations to be reduced modulo n along the way.
- 24
If a is congruent to b modulo n and c is a positive integer, what can be said about ac and bc?
Model answer
ac is congruent to bc modulo n.
Explanation
Repeated multiplication preserves congruence; the result can also be proved by induction on c.
- 25
Does congruence of exponents generally allow one to replace an exponent in a modular power?
Model answer
No. In general, congruent exponents do not guarantee congruent powers.
Explanation
For example, 1 and 6 are congruent modulo 5, but (−1)1=−1 is not congruent to (−1)6=1 modulo 5.
- 26
Why is the claim that congruent exponents always give congruent powers disproved by (−1)1 and (−1)6 modulo 5?
Model answer
Although 1 and 6 are congruent modulo 5, the powers are −1 and 1, which are not congruent modulo 5.
Explanation
A single counterexample disproves a claim intended to hold generally.
- 27
How can the remainder of a large power be computed more efficiently than evaluating the entire power first?
Model answer
Reduce the base modulo the modulus, then repeatedly multiply and reduce intermediate results to find a manageable pattern.
Explanation
Congruence is preserved under multiplication, so reducing intermediate values gives the same final remainder.
- 28
What pattern do the powers of 35 follow modulo 100 after the first power?
Model answer
Odd powers greater than 1 have remainder 75, while even powers have remainder 25.
Explanation
For example, 352≡25, 353≡75, and 354≡25(mod100); the pattern then alternates.
- 29
Why must a sequence of powers modulo 100 eventually repeat a remainder?
Model answer
There are only 100 possible remainders modulo 100, so a sufficiently long sequence of powers must repeat a value.
Explanation
Once a remainder repeats, subsequent powers repeat in a cycle because each next power is obtained by multiplying by the same base.
- 30
Does the repeating pattern of powers modulo a number always begin quickly or have a short period?
Model answer
No. A pattern eventually repeats, but it may be harder to find and may have a longer period than the example modulo 100.
Explanation
The finite number of possible remainders guarantees eventual repetition, not a particular starting point or cycle length.
- 31
What does it mean for x to have a multiplicative inverse modulo n?
Model answer
A multiplicative inverse of x modulo n is a number y such that xy≡1(modn).
Explanation
It is the modular analogue of a number that multiplies x to give 1.
- 32
Give a multiplicative inverse pair modulo 5 from the lecture.
Model answer
2 and 3 are inverses modulo 5, since 2⋅3=6≡1(mod5).
Explanation
Their product differs from 1 by a multiple of 5.
- 33
When does an integer a have a multiplicative inverse modulo n?
Model answer
It has an inverse modulo n if and only if gcd(a,n)=1.
Explanation
An inverse exists exactly when 1 can be expressed as an integer linear combination of a and n, which occurs precisely when their gcd is 1.
- 34
How does Bézout’s identity show that a has an inverse modulo n when gcd(a,n)=1?
Model answer
Bézout’s identity gives integers b and q with ab+qn=1, so ab≡1(modn) and b is an inverse of a.
Explanation
The integer linear combination becomes a multiplicative-inverse equation when reduced modulo n.
- 35
Why can 3 not be canceled from 3x≡3(mod6) to conclude x≡1(mod6)?
Model answer
Because gcd(3,6)=3, not 1, so 3 has no multiplicative inverse modulo 6; in fact, x=3 satisfies the original congruence but not the proposed conclusion.
Explanation
Indeed, 3⋅3=9≡3(mod6), while 3≡1(mod6).
- 36
Under what condition can a coefficient be canceled from a congruence modulo n?
Model answer
A coefficient can be canceled when it is relatively prime to the modulus.
Explanation
If the coefficient’s gcd with the modulus is 1, it has a multiplicative inverse that can be multiplied through the congruence.
- 37
Solve 3x≡3(mod5) using a multiplicative inverse.
Model answer
Since 2 is the inverse of 3 modulo 5, multiplying both sides by 2 gives x≡1(mod5).
Explanation
The gcd of 3 and 5 is 1, and 2⋅3≡1(mod5).
- 38
Solve 7x≡14(mod30) using an inverse of 7.
Model answer
7−1≡13(mod30), so multiplying both sides by 13 gives x≡2(mod30).
Explanation
Since 7⋅13=91≡1(mod30), multiplying the right-hand side gives 14⋅13≡2(mod30).
- 39
State Fermat’s Little Theorem.
Model answer
If p is prime and a is not divisible by p, then ap−1≡1(modp).
Explanation
The condition that a is not divisible by p is essential to the theorem as stated.
- 40
Why must the condition that a is not divisible by p be included in Fermat’s Little Theorem?
Model answer
If a is divisible by p, then ap−1≡0(modp), not 1.
Explanation
The theorem requires a to be nonzero modulo the prime p.
- 41
In what sense can Fermat’s Little Theorem help reduce exponents modulo a prime?
Model answer
For a base not divisible by prime p, a factor of ap−1 can be replaced by 1 modulo p, so exponents can be reduced by multiples of p−1.
Explanation
This is a special exponent-reduction rule modulo a prime, rather than a general rule for replacing exponents by congruent ones.
- 42
For prime p and a not divisible by p, what can be said about the values a,2a,…,(p−1)a modulo p?
Model answer
They are all nonzero and pairwise distinct modulo p.
Explanation
None is divisible by p; if ia≡ja(modp), then a can be canceled because it has an inverse modulo p, giving i≡j(modp).
- 43
Why can a be canceled in the proof that the values a,2a,…,(p−1)a are distinct modulo p?
Model answer
Because p is prime and does not divide a, so gcd(a,p)=1 and a has an inverse modulo p.
Explanation
Multiplying a congruence by this inverse shows that equal products imply equal coefficients modulo p.
- 44
What set of residues do the nonzero values a,2a,…,(p−1)a represent modulo p?
Model answer
They represent all the nonzero residues modulo p, each exactly once.
Explanation
There are p−1 distinct nonzero values, matching the p−1 nonzero residue classes modulo p.
- 45
How does multiplying the residues in the proof of Fermat’s Little Theorem produce a factorial expression?
Model answer
The product of the coefficients 1,2,…,p−1 is (p−1)!, while the product of a,2a,…,(p−1)a is ap−1(p−1)!.
Explanation
Each of the p−1 terms in the second product contributes one factor of a.
- 46
Why can (p−1)! be canceled in the proof of Fermat’s Little Theorem?
Model answer
None of 1,2,…,p−1 is divisible by p, so (p−1)! is relatively prime to p and has an inverse modulo p.
Explanation
Canceling this invertible factor from the product congruence yields ap−1≡1(modp).
- 47
Use Fermat’s Little Theorem to reduce 795 modulo 13 to a smaller power.
Model answer
Since 13 is prime and 95≡11(mod12), 795≡711(mod13).
Explanation
Fermat’s Little Theorem gives 712≡1(mod13), allowing the exponent to be reduced modulo 12.
- 48
What is the remainder of 795 modulo 13?
Model answer
The remainder is 2.
Explanation
After reducing to 711, note that 711⋅7=712≡1(mod13); since 7−1≡2(mod13), 711≡2(mod13).

Ask anything
We've read this whole study set, so questions about it get the best answers.