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
012345678mod 9

Find 107 mod 9, the remainder r with 0 ≤ r < 9.

a = 107n = 9
107 mod 9 =
2.Easy
012345mod 6

Find (−139) mod 6, the remainder r with 0 ≤ r < 6.

a = −139n = 6
(−139) mod 6 =
3.Medium

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

n = 51 = 3·17
φ(51) =
4.Medium

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

n = 19 = 19
φ(19) =
5.Hard

Use repeated squaring to find 1362 mod 45.

a = 13k = 62n = 45
1362 mod 45 =
6.Hard
813c = me​ mod n?m = cd​ mod nm(n, e) = (2021, 19)d

Encrypt the message m = 813 with the RSA public key (n, e) = (2021, 19). Find the ciphertext c.

n = 2021e = 19m = 813
c =

Answer key

  1. 1. 107 mod 9 = 8
  2. 2. (−139) mod 6 = 5
  3. 3. φ(51) = 32
  4. 4. φ(19) = 18
  5. 5. 1362 mod 45 = 34
  6. 6. c = 1728

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