---
title: "How to Write a Maths Proof: A Beginner's Guide with Examples"
description: "What a proof is, why examples are not enough, and four methods (direct, contradiction, induction, counterexample) with worked examples."
slug: how-to-write-a-maths-proof
canonical: https://learn.modernagecoders.com/blog/how-to-write-a-maths-proof/
date: 2026-09-28
dateModified: 2026-09-28
category: "Mathematics"
tags: ["Proof", "Olympiad", "Number Theory", "Python"]
keywords: ["how to write a proof", "how to write a maths proof", "types of proof", "proof by induction examples", "proof by contradiction examples", "what is a mathematical proof", "olympiad proof writing"]
readTime: "9 min read"
author: "Modern Age Coders Team"
---
# How to Write a Maths Proof: A Beginner's Guide with Examples

> Why checking examples is never enough, and the four methods that cover most beginner proofs, each with a worked example and a little code to show where checking ends and proof begins.

![How to write a maths proof: a short proof that the sum of two odd numbers is even, ending with a proof square](/images/blog/how-to-write-a-maths-proof/00-hero.png)

*By Modern Age Coders Team · 2026-09-28 · 9 min read*

**Quick answer:** A proof shows a statement is true in every case, not just the ones you checked. Examples are never enough: n squared plus n plus 41 is prime for 40 values in a row, then fails at n = 40 with 1681 = 41 x 41. Most beginner proofs use four methods: direct proof (reason step by step, often writing odd numbers as 2k + 1), contradiction (assume it is false and reach something impossible, as in the proof that the square root of 2 is not a fraction), induction (prove the first case and that each case gives the next), and counterexample (one failing case disproves an always claim).

A proof is an argument that shows a statement is true in every case, not just the ones you happened to check. It is the heart of mathematics, the main skill tested in maths olympiads, and a big step for anyone moving from school maths to university maths. It also feels strange at first, because most school maths asks you to calculate an answer, not to explain why something must always be true.

This guide explains what a proof is, why checking examples is never enough, and the four methods that cover most beginner proofs: direct proof, proof by contradiction, proof by induction and counterexamples. Each comes with a worked example, and a few short Python programs show where checking stops and proving has to take over.

## Why checking examples is not a proof

Here is a formula studied by Leonhard Euler in the 18th century: n² + n + 41. Try n = 0 and you get 41, a prime. n = 1 gives 43, also prime. n = 2 gives 47. It looks as if this formula always makes primes. Let a computer check:

**euler.py**

```python
def is_prime(n):
    if n < 2:
        return False
    d = 2
    while d * d <= n:
        if n % d == 0:
            return False
        d += 1
    return True

streak = 0
for n in range(100):
    value = n * n + n + 41
    if not is_prime(value):
        print(f"n = {n}: {value} is NOT prime ({value} = 41 x {value // 41})")
        break
    streak += 1
print(f"prime for every n from 0 to {streak - 1}: {streak} cases in a row")
```

**Output**

```text
n = 40: 1681 is NOT prime (1681 = 41 x 41)
prime for every n from 0 to 39: 40 cases in a row
```

![Values of n squared plus n plus 41 for n from 0 to 40: all prime from 41 up to 1601, then at n equals 40 the value is 1681, which is 41 times 41](/images/blog/how-to-write-a-maths-proof/01-euler.png)

*Forty cases in a row, and the claim is still false.*

It gives a prime 40 times in a row, then fails at n = 40: 1681 is 41 × 41. And you can see why without a computer: when n = 40, n² + n + 41 = 40 × 41 + 41 = 41 × 41. Forty examples felt like overwhelming evidence, and they proved nothing. That is exactly why mathematicians insist on proof.

## The four main methods

![Four proof methods: direct proof, reasoning from what you know; contradiction, assuming the claim is false and reaching something impossible; induction, proving the first case and that each case forces the next; and counterexample, one failing case disproves an always claim](/images/blog/how-to-write-a-maths-proof/02-methods.png)

*Most beginner proofs use one of these four.*

### 1. Direct proof

Start from what you know and reason, one justified step at a time, to what you want to show. The trick is usually to write the objects in a useful form. Every odd number can be written as 2m + 1 for some whole number m, so:

- **Claim:** the sum of two odd numbers is even.
- **Proof:** let the odd numbers be 2m + 1 and 2n + 1, where m and n are whole numbers. Their sum is 2m + 2n + 2 = 2(m + n + 1). That is 2 times a whole number, so it is even.

Notice that this covers *every* pair of odd numbers at once, because m and n can be anything. The same style shows that the square of an odd number is odd: (2k + 1)² = 4k² + 4k + 1 = 2(2k² + 2k) + 1, which is 2 times a whole number plus 1. We will need that fact in a moment.

### 2. Proof by contradiction

Assume the statement you want to prove is false, then show that this assumption leads to something impossible. If the assumption breaks mathematics, it must be wrong, so the statement is true. The classic example, known since ancient Greece, shows that the square root of 2 cannot be written as a fraction:

![Proof that the square root of 2 is not a fraction: assume it equals a over b in lowest terms, so a squared equals 2 b squared, so a is even, then b is even, so both are even, contradicting lowest terms](/images/blog/how-to-write-a-maths-proof/04-sqrt2.png)

*Each line follows from the one before. The last line contradicts the first.*

1. Suppose √2 = a / b, where a and b are whole numbers and the fraction is in lowest terms, so a and b have no common factor.
2. Squaring both sides gives 2 = a² / b², so a² = 2b². That means a² is even.
3. If a were odd, a² would be odd, as we just proved. So a must be even. Write a = 2k.
4. Then (2k)² = 2b², so 4k² = 2b², so b² = 2k². So b² is even, and by the same argument, b is even.
5. Now a and b are both even, so they share the factor 2. But we said the fraction was in lowest terms. Contradiction. So √2 is not a fraction.

Another famous contradiction proof is Euclid's argument that the primes never run out, which our [prime numbers guide](/blog/prime-numbers-explained) walks through.

### 3. Proof by induction

Induction proves a statement for every whole number n. You prove two things: the **base case**, that it is true for n = 1, and the **inductive step**, that whenever it is true for some number k, it is also true for k + 1. Together, these knock over every case, like dominoes.

![Induction as dominoes: the base case knocks over the first domino, the inductive step shows each domino knocks over the next, so they all fall and the claim is true for every n](/images/blog/how-to-write-a-maths-proof/03-induction.png)

*Two small proofs give you infinitely many cases.*

**Claim:** 1 + 2 + 3 + ... + n = n(n + 1) / 2 for every whole number n of at least 1. A computer can check lots of cases:

**gauss.py**

```python
# Check the formula 1 + 2 + ... + n = n(n + 1) / 2 for the first 10,000 values of n
total = 0
for n in range(1, 10_001):
    total += n
    assert total == n * (n + 1) // 2, n
print("formula matches for n = 1 to 10,000")
print("but that is 10,000 cases, not all of them. Induction covers the rest.")
```

**Output**

```text
formula matches for n = 1 to 10,000
but that is 10,000 cases, not all of them. Induction covers the rest.
```

Ten thousand cases is encouraging, but after the Euler example we know that is not enough. Here is the proof:

- **Base case:** for n = 1, the left side is 1 and the right side is 1 × 2 / 2 = 1. True.
- **Inductive step:** assume 1 + 2 + ... + k = k(k + 1) / 2. Add k + 1 to both sides: 1 + 2 + ... + k + (k + 1) = k(k + 1) / 2 + (k + 1) = (k + 1)(k / 2 + 1) = (k + 1)(k + 2) / 2. That is exactly the formula with n = k + 1.
- **Conclusion:** the formula holds for n = 1, and each case gives the next, so it holds for every n.

### 4. Disproof by counterexample

To show that an "always" statement is false, you need only one case where it fails. Consider the claim: "if p is prime, then 2p − 1 is prime." Numbers of this form are named after Marin Mersenne, a 17th-century French scholar. It works for the first few primes:

**mersenne.py**

```python
# Claim to test: "if p is prime, then 2^p - 1 is prime"
def smallest_factor(m):
    d = 2
    while d * d <= m:
        if m % d == 0:
            return d
        d += 1
    return None   # no factor found, so m is prime

for p in [2, 3, 5, 7, 11, 13]:
    m = 2 ** p - 1
    f = smallest_factor(m)
    if f is None:
        print(f"p = {p:>2}: 2^p - 1 = {m} is prime")
    else:
        print(f"p = {p:>2}: 2^p - 1 = {m} = {f} x {m // f}, NOT prime")
```

**Output**

```text
p =  2: 2^p - 1 = 3 is prime
p =  3: 2^p - 1 = 7 is prime
p =  5: 2^p - 1 = 31 is prime
p =  7: 2^p - 1 = 127 is prime
p = 11: 2^p - 1 = 2047 = 23 x 89, NOT prime
p = 13: 2^p - 1 = 8191 is prime
```

p = 11 gives 2047 = 23 × 89. That single counterexample disproves the claim for good, even though p = 13 works again. Computers are excellent at hunting for counterexamples, which is one reason coding and proof make good partners.

## How to write a proof up

1. **State exactly what you are proving.** Write the claim in full, including what kind of numbers it is about.
2. **Say what you assume.** "Let n be an odd number", "Suppose, for contradiction, that...".
3. **Give a reason for every step.** Each line should follow from earlier lines, known facts, or the assumptions. If you write "clearly", check that it really is clear.
4. **Use words, not just symbols.** "So", "therefore", "because" and "which means" carry the logic. A proof is a piece of writing.
5. **End by saying what you have shown,** and, for contradiction or induction, why the method finishes the job.

> **The most common beginner mistakes**

> Checking examples and calling it a proof. Assuming the thing you are trying to prove. Proving the converse by accident (showing "if B then A" when asked for "if A then B"). In induction, forgetting the base case, or proving the step only for one particular k.

| When the claim says... | Try first |
| --- | --- |
| for all odd or even numbers | Direct proof, writing numbers as 2k or 2k + 1 |
| something is impossible, or is not a fraction | Contradiction |
| for every whole number n, with a formula in n | Induction |
| is always true, and you suspect it is not | Search for a counterexample, by hand or with code |
| some box must contain two objects | The [pigeonhole principle](/blog/pigeonhole-principle-explained) |

## How to get better at proofs

Proof writing improves with practice and feedback, like any writing. Start with short claims about odd and even numbers, divisibility and sums, then move on. Try each proof yourself before reading one, and after reading a proof, close the book and rewrite it from memory. Our post on [why you can understand solutions but not solve problems](/blog/why-can-i-understand-solutions-but-not-solve-problems) explains why that last step matters so much. Remainders turn up in many proofs, so [modular arithmetic](/blog/modular-arithmetic-explained) is a good next topic.

> A calculation tells you what is true. A proof tells you why it could not be otherwise.

## How we teach it

Proof is where two principles on our [how we teach](/how-we-teach) page matter most: students derive the rule themselves before they ever see it written down, and students explain their thinking. A proof is exactly that, a rule you have reasoned out and can explain. Our [maths olympiad classes](/maths-olympiad-classes-online) run one to one or in small groups of 5 to 10.

[Book a free class](/book-demo) [Book a priority demo](/book-demo)

## Frequently asked questions

**What is a mathematical proof?**

A proof is a logical argument that shows a statement is true in every case it covers. Each step follows from definitions, known facts or earlier steps, so no example, however many you check, can replace it.

**What are the main types of proof?**

For beginners, the four main methods are direct proof, proof by contradiction, proof by induction and disproof by counterexample. Other methods, such as the pigeonhole principle and proof by cases, build on these.

**Why are examples not enough to prove something?**

Because a pattern can hold for many cases and then fail. The formula n squared plus n plus 41 gives a prime for every n from 0 to 39, then gives 1681, which is 41 times 41, at n = 40.

**How do you start a proof?**

Write down exactly what you are proving and what you are allowed to assume. Then rewrite the objects in a useful form, for example an odd number as 2k + 1, and look for a chain of steps from the assumptions to the claim.

**What is proof by induction in simple words?**

You show a statement is true for the first case, then show that whenever it is true for one case, it must also be true for the next. Like dominoes, the first falls and each knocks over the next, so all of them fall.

**What is proof by contradiction?**

You assume the statement is false and show that this assumption leads to something impossible. Since the assumption cannot be right, the statement must be true. The proof that the square root of 2 is not a fraction is a classic example.

**At what age can students learn to write proofs?**

Simple proofs about odd and even numbers suit many students from around 11 or 12, especially those preparing for maths olympiads. Formal proof writing is usually developed further in later secondary school and at university.

---

*Source: https://learn.modernagecoders.com/blog/how-to-write-a-maths-proof/*
