Get started

Modular arithmetic Can 2027 be written as the sum of two square numbers?

Maths olympiad · 45 minutes

Able students try to write 2027 as two squares and fail, find which remainders squares can leave on a graph, then learn to add, multiply and power remainders, test for 3 and 9 by digit sums, and rule equations out in a line. It comes with slides, a vote that shows who's stuck, practice up to olympiad proofs, and homework.

You can present and print it without signing in.

Use in my lessons

Free. The whole lesson is copied into your Library for you to change.

Each step is the remainder when x² is divided by m, for x = 0, 1, 2, … Start at m = 4: which remainders ever appear? Move m to 3, 8 and 9. Which remainders never appear, and why does the pattern repeat?

36912

At x = 0, 1, 2 …: 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0

The idea in one minute

Two numbers are congruent modulo n, written a ≡ b (mod n), when they leave the same remainder on dividing by n. Remainders can be added, subtracted, multiplied and raised to powers, so big numbers shrink: 2 ≡ −1 (mod 3), so 2¹⁰⁰ ≡ 1. As 10 ≡ 1 (mod 9), every number is congruent to its digit sum modulo 9 and modulo 3. And squares leave only a few remainders: 0 or 1 modulo 3 and modulo 4; 0, 1 or 4 modulo 8. So a sum of two squares leaves 0, 1 or 2 on dividing by 4, never 3, and 2027 is not one.

The lesson builds on last digits, which were arithmetic modulo 10. It is problem first: students hunt for two squares adding to 2027, see on a graph which remainders squares leave, and only then learn the rules and the notation. A remainder test proves an equation has no solutions; when the test is passed it proves nothing, and another modulus may still rule it out.

By the end, students can

  • write and use a ≡ b (mod n), and find remainders of sums, products and powers
  • use −1 to find remainders of large powers
  • find remainders on dividing by 3 and 9 from the digit sum, and say why it works
  • list the remainders squares leave modulo 3, 4 and 8
  • prove an equation has no whole-number solutions by choosing a modulus

Key words

  • remainder
  • congruent
  • modulo
  • digit sum
  • square residues
  • no solutions

Before this lesson

Students should divide with a remainder, find last digits of powers by their cycles (the last-digits lesson), and expand (2k + 1)².

Taught in Last digits and cycles.

The lesson, step by step

45 minutes in total. The stretch is optional.

  1. 1 · Think5 min

    Two squares for 2027

    2026 = 45² + 1² = 2025 + 1

    Find two square numbers that add up to 2027.

    Or: can you show that there are none?

    Three minutes. Is one square odd and one even?

    Write here

    5 min 1 · Hook · students think · the slides say “Think”

    Two squares for 2027

    Students hunt for two squares that add to 2027 before anyone explains.

    Say

    “2026 is 45² + 1². Find two square numbers that add up to 2027. You have three minutes; a calculator is fine.”

    Ask
    • Must one of the squares be odd and the other even? Why?
    • How many pairs would you have to try to be sure?
    Watch for

    Students who try a few pairs and say 'it can't be done': ask how they know they haven't missed one.

    For the teacher

    Three minutes of searching. The good start: 2027 is odd, so one square is odd and the other even.

    Ask how many pairs there are (x up to 45) and whether trying them all is a proof. It is, but a slow one. The lesson finds a proof that works for 2027, 2031, 4031 and every number like them at once.

    Some try 44² = 1936 and 2027 − 1936 = 91, not a square; others go down the list. Take a vote with Ask the class: possible or not? Don't settle it: the lesson proves it in one line.

    Shorter: One minute of searching; vote straight away (−2 min).

  2. 2 · Watch12 min

    Same remainder: congruent

    a ≡ b (mod n): a and b leave the same remainder on ÷ n

    Or: n divides a − b

    17 ≡ 5 (mod 4): both leave 1, and 4 divides 12

    Last digits were remainders mod 10.

    Try it: is 2026 ≡ 1 (mod 9)?

    2 · Watch

    Shrink first, then work

    Remainders add, subtract, multiply and power:

    if a ≡ b, then a + c ≡ b + c, ac ≡ bc, aᵏ ≡ bᵏ

    Use −1: 2 ≡ −1 (mod 3), so 2¹⁰⁰ ≡ (−1)¹⁰⁰ = 1

    Never divide: 6 ≡ 2 (mod 4), but 3 ≢ 1 (mod 4)

    What does 2¹⁰¹ leave on dividing by 3?

    2 · Watch

    Why digit sums work

    10 ≡ 1 (mod 9), so 100 ≡ 1, 1000 ≡ 1, …

    5678 = 5 × 1000 + 6 × 100 + 7 × 10 + 8

    So 5678 ≡ 5 + 6 + 7 + 8 = 26 ≡ 8 (mod 9)

    The same for 3. Not for 4 or 7: 10 ≢ 1 there.

    1234 × 5678: its remainder on dividing by 9?

    2 · Watch

    What squares leave

    Remainder of x² on dividing by m

    m = 4: 0, 1, 0, 1, …

    (2k)² = 4k²: leaves 0

    (2k + 1)² = 4k² + 4k + 1: leaves 1

    Move m to 3 and to 8.

    Which remainders never appear?

    2 · Watch

    Rule it out

    Two squares leave 0 + 0, 0 + 1 or 1 + 1 on ÷ 4.

    2027 = 4 × 506 + 3 leaves 3. No solutions.

    But 2026 leaves 2: not ruled out, and 45² + 1².

    2022 leaves 2 as well, yet mod 8 rules it out.

    A test that is passed proves nothing.

    No from one modulus is a proof. Yes is not.

    12 min 2 · Explain · you explain · the slides say “Watch”

    Work with remainders

    Congruences and their rules, digit sums for 3 and 9, then the remainders squares leave.

    Say

    “From now on, we only care about remainders. 2027 leaves 3 on dividing by 4. What can a square leave?”

    Ask
    • 17 and 5 leave the same remainder on dividing by 4. What divides 17 − 5?
    • 10 leaves 1 on dividing by 9. What does 100 leave? 1000?
    • An even number squared, (2k)²: what does it leave on dividing by 4? An odd one, (2k + 1)²?
    Watch for

    Students who read the squares mod 4 as 0, 1, 4, 9: the remainders must be under 4, and 4 and 9 leave 0 and 1.

    Remainders multiply

    1234 ≡ 1 + 2 + 3 + 4 = 10 ≡ 1 (mod 9)

    5678 ≡ 5 + 6 + 7 + 8 = 26 ≡ 8 (mod 9)

    1234 × 5678 ≡ 1 × 8 = 8 (mod 9)

    Squares mod 4

    (2k)² = 4k²: remainder 0

    (2k + 1)² = 4k² + 4k + 1: remainder 1

    So squares leave 0 or 1, and two of them 0, 1 or 2

    2027 ruled out

    2027 = 4 × 506 + 3, so 2027 ≡ 3 (mod 4)

    a² + b² ≡ 0, 1 or 2 (mod 4), never 3

    So 2027 is not a sum of two squares

    For the teacher

    First slide: congruence. a ≡ b (mod n) means a and b leave the same remainder on dividing by n, or n divides a − b. 17 ≡ 5 (mod 4). It builds on last digits: those were remainders mod 10.

    Second slide: the rules. Remainders can be added, subtracted, multiplied and powered: if a ≡ b then a + c ≡ b + c, ac ≡ bc, aᵏ ≡ bᵏ. Negative remainders help: 2 ≡ −1 (mod 3), so 2¹⁰⁰ ≡ (−1)¹⁰⁰ = 1. Never divide.

    Third slide: digit sums. 10 ≡ 1 (mod 9), so 100 ≡ 1, 1000 ≡ 1, and 5678 = 5 × 1000 + 6 × 100 + 7 × 10 + 8 ≡ 5 + 6 + 7 + 8 (mod 9). The same for 3. That is why the tests for 3 and 9 work, and why there is no such test for 4 or 7.

    Fourth slide: squares. On the graph, squares mod 4 are 0, 1, 0, 1, …; mod 3 the same; mod 8 they are 0, 1, 4, 1, 0, 1, 4, 1. Prove the mod 4 case with (2k)² and (2k + 1)².

    Fifth slide: rule it out. Two squares add to 0, 1 or 2 mod 4; 2027 ≡ 3, so no. Then the warning: 2026 ≡ 2 passes the test, and is 45² + 1²; 2022 ≡ 2 passes too, but mod 8 rules it out. A passed test proves nothing.

    The graph is the hook's: move m and read off the remainders of squares. Mod 3: 0, 1. Mod 4: 0, 1. Mod 8: 0, 1, 4. Mod 9: 0, 1, 4, 7. The pattern repeats every m because (x + m)² leaves what x² leaves.

    Shorter: Show the rules and the digit sums as one slide (−4 min).

  3. 3 · Your turn8 min

    A worked example, then yours

    I do: 1234 × 5678 on ÷ 9: digit sums 1 and 8, so 8

    You do: 2345 × 6789 on dividing by 9

    I do: 2¹⁰⁰ on ÷ 3: 2 ≡ −1, so (−1)¹⁰⁰ = 1

    You do: 5⁹⁹ on dividing by 6

    Shrink each number to its remainder first.

    Write here

    3 · Your turn

    Rule it out, or not

    I do: x² + y² = 2027. 2027 ≡ 3 (mod 4): none.

    You do: x² + y² = 2026.

    Does mod 4 rule it out? Is there a solution?

    If the test doesn't say no, look for a solution.

    Write here

    The answers slide comes with your copy.

    8 min 3 · Your turn · students write

    A worked example, then yours

    Each worked example beside a twin that students solve themselves.

    Say

    “Watch me shrink each number to its remainder first, then work. Then you do the twin.”

    Ask
    • Which modulus, and why that one?
    • Is there a remainder near 0, such as −1?
    Watch for

    A passed test taken as a proof: 2026 passes mod 4, and that alone doesn't show it is a sum of two squares.

    A product mod 9

    1234 × 5678 on dividing by 9

    Digit sums: 1234 ≡ 1, 5678 ≡ 8

    1 × 8 = 8: the remainder is 8

    Then their turn

    2345 × 6789 on dividing by 9: the remainder?

    A power, by −1

    2¹⁰⁰ on dividing by 3

    2 ≡ −1 (mod 3), so 2¹⁰⁰ ≡ (−1)¹⁰⁰ = 1

    The remainder is 1

    Then their turn

    5⁹⁹ on dividing by 6: the remainder?

    Rule it out, or not

    x² + y² = 2027: 2027 ≡ 3 (mod 4)

    Two squares leave 0, 1 or 2: no solutions

    Then their turn

    x² + y² = 2026: does mod 4 rule it out? Is there a solution?

    For the teacher

    Work the first example aloud, digit sums first. Students do the twin: 2345 ≡ 14 ≡ 5, 6789 ≡ 30 ≡ 3, and 15 ≡ 6.

    The second pair uses −1: 5 ≡ −1 (mod 6), so an odd power is ≡ −1, written as 5. The third pair shows a test that rules out, then one that doesn't.

    Open the answers slide once most have finished. The third twin is a trap: 2026 ≡ 2 (mod 4) is not ruled out, and 45² + 1² = 2026. The test only ever says no.

    Shorter: Do the second and third pairs only (−3 min).

  4. 4 · Vote and practise15 min

    Vote first

    n is a whole number.

    What remainders can n² leave on dividing by 4?

    A: any of 0, 1, 2 and 3

    B: 0 and 1 only

    C: 1 only

    D: 0, 1, 4 and 9

    Choose on your own, then say why.

    4 · Vote and practise

    Climb: remainders

    1. 2026 on dividing by 3, by 4, by 9?

    2. 123456789 on dividing by 9?

    3. 47□2 divides by 9: the missing digit?

    4. 2²⁰²⁶ on dividing by 3?

    5. Not a sum of two squares: 2025, 2026, 2027, 2029?

    Stuck? Shrink every number to its remainder first.

    Write here

    4 · Vote and practise

    Reason, then prove

    6. Mod 4 allows x² + y² = 2022. A solution?

    7. Prove x² − 3y² = 2 has no whole-number solutions.

    8. 1! + 2! + … + 100! on dividing by 9?

    9. 8k + 7 is never a sum of three squares.

    Which modulus? List what each side can leave.

    Write here

    15 min 4 · Who's stuck? · students vote · the slides say “Vote and practise”

    Vote, then climb

    One question shows who's stuck; then practice from remainders to olympiad proofs.

    Say

    “Choose an answer on your own. Nobody talks until everyone has chosen.”

    Ask
    • What do 0², 1², 2², 3² leave on dividing by 4?
    • Why is checking 0 to 3 enough?
    Watch for

    Squares listed without reducing; only odd numbers tried; a remainder of 4 or 9 'on dividing by 4'.

    Show your working: shrink each number to its remainder first. For proofs, say which modulus and list what each side can leave.

    The question that shows who's stuck

    1. n is a whole number. What remainders can n² leave on dividing by 4?
      1. Any of 0, 1, 2 and 3
      2. 0 and 1 only
      3. 1 only
      4. 0, 1, 4 and 9
    An example of what your Classroom shows as they answer
    • A5
    • B12
    • C7
    • D6

    Each wrong answer points to a different mistake. As they answer, your Classroom shows who chose what, so you can see in seconds who needs help, and with what.

    1. 2026 leaves ___ on dividing by 3, ___ on dividing by 4, and ___ on dividing by 9.
    2. What is the remainder when 123456789 is divided by 9?
    3. The four-digit number 47□2 divides by 9. The missing digit is ___.
    4. What is the remainder when 2²⁰²⁶ is divided by 3?
    5. Which of these is not a sum of two square numbers?
      1. 2025
      2. 2026
      3. 2027
      4. 2029
    6. Kai says: 'Mod 4 doesn't rule out x² + y² = 2022, so it has a whole-number solution.' Is he right?
      1. Yes: if mod 4 allows it, a solution must exist
      2. No: 2022 ≡ 2 (mod 4) means x and y are odd, and two odd squares add to 2 (mod 8), but 2022 ≡ 6 (mod 8)
      3. Yes: 2022 is even, so it is twice a number, and that always works
    7. Prove that x² − 3y² = 2 has no whole-number solutions.
    8. Stretch: what is the remainder when 1! + 2! + 3! + … + 100! is divided by 9?
    9. Stretch: prove that no number that leaves 7 on dividing by 8 is a sum of three square numbers.

    Support · Shrink every number to its remainder first. For squares mod n, square 0, 1, …, n − 1 and reduce. To rule out an equation, try mod 3, 4, 8 or 9 and compare both sides.

    For the teacher

    Everyone chooses before anyone explains. Then ask for each answer's reasoning: unreduced squares, odd numbers only and 'any remainder' all show here.

    Questions 1–3 are remainders and digit sums; 4–6 change the look and ask why; 7 is a first written proof. 8 and 9 are olympiad level: factorials mod 9, and three squares mod 8.

    Students write proofs on paper or the board; the quiz keeps their answers for you to mark and comment on.

    If the class is split, make the table together: x from 0 to 7, x², and the remainder on dividing by 4. Long answers (7, 9) are marked by you: a mark for the modulus, one for the list of possible remainders, one for the conclusion. Model answers are in each question's explanation.

    Shorter: After the vote, questions 1–5 only (−6 min).

    Longer: Swap and mark: pairs mark each other's proof of question 7, then 9 (+10 min).

  5. 5 · Show what you know5 min

    Choose the modulus

    Prove that x² − 3y = 2027 has no whole-number solutions.

    Say which modulus you use, and why.

    The modulus, what squares leave, and why it can't work.

    Write here

    5 min 5 · Exit · students show · the slides say “Show what you know”

    Choose the modulus

    One proof with a modulus students choose shows who has the whole idea.

    Say

    “A few lines: the modulus, what squares leave, and why it can't work.”

    Watch for

    Mod 4 tried, found to allow it, and the answer 'so there are solutions'.

    A few lines: the modulus, what squares leave, and why it can't work.

    1. Prove that x² − 3y = 2027 has no whole-number solutions. Say which modulus you use, and why.
    For the teacher

    Prove that x² − 3y = 2027 has no whole-number solutions.

    Say which modulus you use, and why.

    Mod 4 doesn't help here (3y can be anything mod 4); mod 3 does. Answers that try mod 4 and stop show who hasn't yet learnt to try another modulus: start there next time. Set the homework.

    Longer: Then prove 3x² + 7 is never a square (mod 3 fails; try 4) (+5 min).

One-to-one: let the student hunt for 2027 as two squares for a few minutes, then make the table of squares mod 4 together, x from 0 to 7. Before each proof ask 'which modulus, and why that one?'.

Homework: remainders and proofs

Shrink each number to its remainder first. For proofs, say which modulus and list what each side can leave.

  1. Find the remainders when 98765 is divided by 9 and by 3, without dividing.
  2. The number 5□38 divides by 9. Find the missing digit.
  3. Find the remainder when 3²⁰²⁷ is divided by 4.
  4. List the remainders n² can leave on dividing by 3, and prove there are no others.
  5. Prove that x² + y² = 1003 has no whole-number solutions.
  6. Prove that n³ − n divides by 3 for every whole number n.
  7. Challenge: prove that 3x² + 7 is never a square number. (Mod 3 doesn't help. Which modulus does?)

Print the worksheet, with space for working and the homework. The answers come with your copy in the Library.

Modular arithmetic: common questions

What does a ≡ b (mod n) mean?

That a and b leave the same remainder on dividing by n, or, the same thing, that n divides a − b. 17 ≡ 5 (mod 4). Remainders can be added, subtracted, multiplied and raised to powers, which is what makes huge numbers easy to handle.

How does this lesson differ from the last-digits lesson?

Last digits are remainders on dividing by 10, found by their cycles. This lesson names the idea for every modulus, adds the rules and the trick of −1, explains the digit-sum tests for 3 and 9, and uses the remainders squares leave to prove equations have no solutions.

Which competitions is this lesson useful for?

It suits able students aged about 13 to 16 preparing for maths challenges and olympiads, such as the UKMT Intermediate and Senior Mathematical Challenges and their follow-on rounds. The problems are our own, written in the style of such competitions, not taken from past papers.

How do students know which modulus to try?

Squares suggest 3, 4 or 8 (few remainders); a term like 3y suggests 3, so it vanishes; digit sums suggest 9. If one modulus allows the equation, try another. The exit question is built so that 4 fails and 3 works.

Can I use the lesson without creating an account?

Yes. You can read the lesson, print the worksheet and open its slides without signing in. Anything you draw on the slides isn't saved. With a free teacher account, you can keep the whole lesson in your Library to change and teach, including the quizzes, the answers and the answer slides.

Teach this lesson tomorrow

Keep the whole lesson, change what you like, and use it with a group. Present its slides step by step while each student works on their own copy.

Use in my lessons

Free. The whole lesson is copied into your Library for you to change.

Written in our own words and free to use with your students. Not endorsed by any exam board.