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
aqbr112=?·42+??=?·?+??=?·?+?

Use Euclid’s algorithm to find gcd(112, 42).

a = 112b = 42
gcd(112, 42) =
2.Easy

Find 641² mod 5 without multiplying out the large numbers: reduce first.

n = 5
641² mod 5 =
3.Medium

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

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

Find the smallest positive integer x with x ≡ 4 (mod 11) and x ≡ 0 (mod 13).

x ≡ 4 (mod 11)x ≡ 0 (mod 13)
x =
5.Hard
mc = me​ mod n431m = cd​ mod n?(n, e) = (799, 7)d

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

p = 17q = 47e = 7c = 431
m =
6.Hard
mc = me​ mod ncm = cd​ mod nm(n, e) = (215, 11)d = ?

An RSA key uses the primes p = 5 and q = 43 and the public exponent e = 11. Find the private exponent d (0 < d < φ(n)).

p = 5q = 43e = 11
d =

Answer key

  1. 1. gcd(112, 42) = 14
  2. 2. 641² mod 5 = 1
  3. 3. 4−1 mod 23 = 6
  4. 4. x = 26
  5. 5. m = 269
  6. 6. d = 107

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