Number theory & modular arithmetic worksheet with answers

Free printable Number theory & modular arithmetic worksheet: 6 problems from easy to exam level, with an answer key. Print it or save it as a PDF.

For teachers: free to print, copy and use in class. Every new worksheet has new values and its own answer key. A link to ExamProblems on your course page is appreciated.

Name: ____________________   Date: ____________

1.Easy
0123456mod 7

Find 89 mod 7, the remainder r with 0 ≤ r < 7.

a = 89n = 7
89 mod 7 =
2.Easy
aqbr148=?·40+??=?·?+??=?·?+??=?·?+?

Use Euclid’s algorithm to find gcd(148, 40).

a = 148b = 40
gcd(148, 40) =
3.Medium

Find the inverse of 4 modulo 19: the number x with 0 < x < 19 and 4·x ≡ 1 (mod 19).

a = 4n = 19
4−1 mod 19 =
4.Medium

Find Euler’s totient φ(221), the number of integers from 1 to 221 that are coprime to 221.

n = 221 = 13·17
φ(221) =
5.Hard
mc = me​ mod ncm = cd​ mod nm(n, e) = (493, 13)d = ?

An RSA key uses the primes p = 17 and q = 29 and the public exponent e = 13. Find the private exponent d (0 < d < φ(n)).

p = 17q = 29e = 13
d =
6.Hard
47c = me​ mod n?m = cd​ mod nm(n, e) = (217, 17)d

Encrypt the message m = 47 with the RSA public key (n, e) = (217, 17). Find the ciphertext c.

n = 217e = 17m = 47
c =

Answer key

  1. 1. 89 mod 7 = 5
  2. 2. gcd(148, 40) = 4
  3. 3. 4−1 mod 19 = 5
  4. 4. φ(221) = 192
  5. 5. d = 69
  6. 6. c = 101

Full step-by-step solutions: practise this topic on examproblems.com.