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
aqbr98=?·26+??=?·?+??=?·?+??=?·?+?

Use Euclid’s algorithm to find gcd(98, 26).

a = 98b = 26
gcd(98, 26) =
2.Easy
01234567mod 8

Find 151 mod 8, the remainder r with 0 ≤ r < 8.

a = 151n = 8
151 mod 8 =
3.Medium

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

a = 35n = 39
35−1 mod 39 =
4.Medium

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

a = 23n = 29
23−1 mod 29 =
5.Hard
mc = me​ mod n21m = cd​ mod n?(n, e) = (253, 7)d

An RSA key uses p = 11, q = 23 and e = 7. Decrypt the ciphertext c = 21: find the message m.

p = 11q = 23e = 7c = 21
m =
6.Hard
718c = me​ mod n?m = cd​ mod nm(n, e) = (1081, 3)d

Encrypt the message m = 718 with the RSA public key (n, e) = (1081, 3). Find the ciphertext c.

n = 1081e = 3m = 718
c =

Answer key

  1. 1. gcd(98, 26) = 2
  2. 2. 151 mod 8 = 7
  3. 3. 35−1 mod 39 = 29
  4. 4. 23−1 mod 29 = 24
  5. 5. m = 43
  6. 6. c = 1022

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