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
01234567mod 8

Find (−77) mod 8, the remainder r with 0 ≤ r < 8.

a = −77n = 8
(−77) mod 8 =
2.Easy
aqbr406=?·336+??=?·?+??=?·?+??=?·?+?

Find the least common multiple lcm(406, 336). Use Euclid’s algorithm for the gcd first.

a = 406b = 336
lcm(406, 336) =
3.Medium

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

a = 27n = 89
27−1 mod 89 =
4.Medium

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

a = 72n = 79
72−1 mod 79 =
5.Hard
mc = me​ mod n39m = cd​ mod n?(n, e) = (217, 17)d

An RSA key uses p = 7, q = 31 and e = 17. Decrypt the ciphertext c = 39: find the message m.

p = 7q = 31e = 17c = 39
m =
6.Hard
87c = me​ mod n?m = cd​ mod nm(n, e) = (533, 13)d

Encrypt the message m = 87 with the RSA public key (n, e) = (533, 13). Find the ciphertext c.

n = 533e = 13m = 87
c =

Answer key

  1. 1. (−77) mod 8 = 3
  2. 2. lcm(406, 336) = 9744
  3. 3. 27−1 mod 89 = 33
  4. 4. 72−1 mod 79 = 45
  5. 5. m = 16
  6. 6. c = 490

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