Skip to content
The Lumenary
Grades 3–5Ages 8–11 40 min

Whole-number arithmetic

Equal groups, arrays and leftovers — and why the written methods for multiplying and dividing really work.

Formally verified · 18 LeanComputationally tested · 2 PythonAI-drafted · awaiting human reviewMathematically reviewed: Awaiting human review

Your guides: Chloe, Margaret, Gideon

MotivationH

Eggs on the farm

Neema helps on her family's farm near Arusha, in Tanzania. One morning the hens have laid 347 eggs. The eggs go to market in trays, and each tray holds 30 eggs.

  • How many trays can Neema fill?
  • How many eggs will be left over?
  • Next week the farm sells 23 full trays. How many eggs is that?

The first two questions are about dividing, the last one about multiplying. You already know how to add and subtract using tens and ones (addition, subtraction and place value). You may also know methods for multiplying and dividing. In this lesson we find out why those methods work, so that you never have to trust a rule you don't understand.

IntuitionH

Equal groups and arrays

Multiplication counts equal groups. Four trays with 66 eggs in each hold 4×6=6+6+6+6=244 \times 6 = 6 + 6 + 6 + 6 = 24 eggs.

We can also set things out in rows and columns, as an array. An array with 44 rows of 66 has 4×64 \times 6 objects. Now turn the array on its side: it becomes 66 rows of 44. Nothing was added and nothing was taken away, so

4×6=6×4.4 \times 6 = 6 \times 4.

That works for any array. Turning it never changes how many things are in it.

An array of unit squares

Change the width and height. Can you find two different rectangles with the same number of squares?

64

4 rows of 6 squares: multiply to count them all.

Area

6 × 4 = 24

24 square units

Area is counted in unit squares. Perimeter is counted in unit lengths, all the way around the edge.

DefinitionsH

The words and laws we need

Definition— multiplication

For whole numbers aa and bb, the product a×ba \times b is the total number of objects in aa equal groups of bb. It is also the number of squares in a rectangle (an array) with aa rows and bb columns.

Multiplication obeys three laws. They are true for all whole numbers aa, bb and cc:

LawIn symbolsExample
Commutativea×b=b×aa \times b = b \times a4×6=6×44 \times 6 = 6 \times 4
Associative(a×b)×c=a×(b×c)(a \times b) \times c = a \times (b \times c)(25×4)×9=25×(4×9)(25 \times 4) \times 9 = 25 \times (4 \times 9)
Distributivea×(b+c)=a×b+a×ca \times (b + c) = a \times b + a \times c7×12=7×10+7×27 \times 12 = 7 \times 10 + 7 \times 2

Two more facts complete the toolkit: a×1=aa \times 1 = a and a×0=0a \times 0 = 0.

Division often does not come out exactly. When it doesn't, something is left over.

Definition— division with remainder

Let aa and bb be whole numbers with b>0b > 0. Dividing aa by bb means finding whole numbers qq and rr with

a=q×b+rand0≤r<b.a = q \times b + r \qquad\text{and}\qquad 0 \le r < b.

The number qq is the quotient (how many full groups) and rr is the remainder (how many are left over). We write a÷b=qa \div b = q remainder rr. Many people shorten "remainder" to "r", as in 23÷5=423 \div 5 = 4 r 33.

The condition r<br < b matters. If rr were bb or more, we could make one more full group!

Worked examplesH

Worked examples

Example— Calculating cleverly

  • 7×987 \times 98: think of 9898 as 100−2100 - 2. So 7×98=7×100−7×2=700−14=6867 \times 98 = 7 \times 100 - 7 \times 2 = 700 - 14 = 686.
  • 25×3625 \times 36: think of 3636 as 4×94 \times 9. So 25×36=(25×4)×9=100×9=90025 \times 36 = (25 \times 4) \times 9 = 100 \times 9 = 900.
  • 4×17×254 \times 17 \times 25: swap and regroup to 17×(4×25)=17×100=170017 \times (4 \times 25) = 17 \times 100 = 1700.
  • Neema's 2323 trays of 3030 eggs: 23×30=(23×3)×10=69×10=69023 \times 30 = (23 \times 3) \times 10 = 69 \times 10 = 690 eggs.

Each step uses one of the laws. That is what makes these tricks correct, not just clever.

Example— Neema's eggs

How many trays of 3030 can be filled from 347347 eggs? Keep taking 3030 away: after 1111 trays, 11×30=33011 \times 30 = 330 eggs are used and 1717 are left. Since 17<3017 < 30, no more full trays can be made:

347=11×30+17.347 = 11 \times 30 + 17.

So 347÷30=11347 \div 30 = 11 remainder 1717.

Example— Small and exact cases

  • 23÷5=423 \div 5 = 4 remainder 33, because 23=4×5+323 = 4 \times 5 + 3 and 3<53 < 5.
  • 30÷6=530 \div 6 = 5 remainder 00. A remainder of 00 means the division is exact.
  • 4÷7=04 \div 7 = 0 remainder 44, because 4=0×7+44 = 0 \times 7 + 4. No full group at all!

Example— A non-example

The equation 23=3×5+823 = 3 \times 5 + 8 is true, but it does not say that 23÷523 \div 5 is 33 remainder 88. The leftover 88 is bigger than 55, so one more group of 55 fits.

Example— What does the remainder mean?

The farm has 10001000 eggs. Then 1000=33×30+101000 = 33 \times 30 + 10. So 3333 trays can be filled. But to hold every egg the farm needs 3434 trays, because the last 1010 eggs need a tray too. The same division can answer different questions, so always ask what the question wants.

Explore

Explore: split, regroup and share

The distributive law as a picture. A rectangle 77 squares tall and 6+46 + 4 squares wide can be cut into two rectangles. Press "Pull the parts apart" and change the sliders:

Area and perimeter

Area counts the unit squares inside a shape; perimeter measures the distance around it.

c = 47 × 4 = 28b = 67 × 6 = 427

7 × (6 + 4) = 7 × 6 + 7 × 4

= 42 + 28 = 70

70 square units

Two rectangles with the same height, side by side, make one big rectangle. So a × (b + c) = a × b + a × c: the distributive law.

a × (b + c) = a × b + a × c

Notice that 7×(6+4)=7×6+7×47 \times (6 + 4) = 7 \times 6 + 7 \times 4, whatever numbers you choose.

Division with remainder as an array. Arrange 2323 dots in rows of 55. You get 44 full rows and 33 dots left over: 23=4×5+323 = 4 \times 5 + 3. Try other row lengths. When are there no dots left over?

Rows of dots, and what is left over

Arrange dots in equal rows. When nothing is left over, you have found a factor pair.

23 = 1 × 23

23 dots make 1 full rows of 23, with nothing left over: 23 and 1 are factors of 23.

Every rectangle you can make with 23 dots (tap one):

23 has 2 factors: 1, 23

23 is prime: the only rectangle is a single row.

ProofH

Why the methods work

Why the laws are true

  • Commutative: turn the array (see above).
  • Associative: build a box of cubes, aa long, bb wide and cc tall. Count it as cc layers of a×ba \times b cubes, or as aa slices of b×cb \times c cubes. Either way it is the same box, so (a×b)×c=a×(b×c)(a \times b) \times c = a \times (b \times c).
  • Distributive: a rectangle aa tall and b+cb + c wide splits into one aa by bb rectangle and one aa by cc rectangle, as in the explorer.

Why the written multiplication method works

Let us multiply 23×4723 \times 47. Place value says 23=20+323 = 20 + 3 and 47=40+747 = 40 + 7. Draw a rectangle 2323 tall and 4747 wide, and cut it along those lines:

40720380014012021
The area model for 23 × 47. The four pieces are 20 × 40 = 800, 20 × 7 = 140, 3 × 40 = 120 and 3 × 7 = 21, so 23 × 47 = 800 + 140 + 120 + 21 = 1081.

The distributive law, used twice, says exactly this:

23×47=(20+3)×(40+7)=20×40+20×7+3×40+3×7=800+140+120+21=1081.\begin{aligned} 23 \times 47 &= (20 + 3) \times (40 + 7) \\ &= 20 \times 40 + 20 \times 7 + 3 \times 40 + 3 \times 7 \\ &= 800 + 140 + 120 + 21 = 1081. \end{aligned}

The column method adds the same four pieces, grouped into rows:

      4 7
    × 2 3
    -----
    1 4 1     ← 47 × 3  = 3 × 40 + 3 × 7  = 120 + 21
    9 4 0     ← 47 × 20 = 20 × 40 + 20 × 7 = 800 + 140
    -----
  1 0 8 1

In the first row, 7×3=217 \times 3 = 21 ones. We write 11 in the ones column and carry the 22. Carrying is not a trick. Twenty ones are two tens, so we move them to the tens column. Then 4×3=124 \times 3 = 12 tens, plus the 22 carried tens, makes 1414 tens: 44 tens and 11 hundred. The second row starts with a 00 because we are multiplying by 22 tens: 47×20=47×2×1047 \times 20 = 47 \times 2 \times 10.

Why long division works

Long division shares out one place value at a time. Here is 953÷4953 \div 4, sharing 953953 among 44 people:

  1. Hundreds. 99 hundreds shared by 44 is 22 hundreds each, using 88. 11 hundred is left.
  2. Trade the leftover hundred for 1010 tens. With the 55 tens we had, that makes 1515 tens. Each person gets 33 tens, using 1212. 33 tens are left.
  3. Trade those 33 tens for 3030 ones. With the 33 ones, that makes 3333 ones. Each person gets 88, using 3232. 11 is left.

Each person got 22 hundreds, 33 tens and 88 ones, so

953=238×4+1,953÷4=238 remainder 1.953 = 238 \times 4 + 1, \qquad 953 \div 4 = 238 \text{ remainder } 1.

Why there is only one quotient and one remainder

Theorem— division with remainder

If b>0b > 0, every whole number aa can be written as a=q×b+ra = q \times b + r with 0≤r<b0 \le r < b, and there is only one such pair qq, rr.

Proof

There is always a pair. Take bb away from aa again and again, as long as at least bb is left. The amount left gets smaller each time, so you must stop. When you stop, fewer than bb are left: that is rr. The number of times you took bb away is qq.

There is only one pair. Picture the multiples of bb on a number line: 0,b,2b,3b,…0, b, 2b, 3b, \dots. They are like fence posts, exactly bb apart. The number aa lies in exactly one gap, from some post q×bq \times b up to (but not including) the next post q×b+bq \times b + b. The remainder rr is how far aa is past that post, and it is less than bb because the next post is bb further on.

Could another pair work? A smaller quotient would put aa more than one whole gap past its post, so its "remainder" would be bb or more. A larger quotient would need a post beyond aa, and then the "remainder" would have to be less than 00. Neither is allowed.

∎

0510152025304 jumps of 5323
Dividing 23 by 5: four jumps of 5 reach 20, and 23 is 3 further on. The next post, 25, is past 23. So 23 = 4 × 5 + 3, and no other quotient works.

Why we cannot divide by zero

"6÷2=36 \div 2 = 3" is a short way to say "33 is the number with 3×2=63 \times 2 = 6". So what would 5÷05 \div 0 be? It would be a number qq with q×0=5q \times 0 = 5. But q×0=0q \times 0 = 0 for every number qq. No number works, so 5÷05 \div 0 has no answer.

And 0÷00 \div 0? Now every number works, because q×0=0q \times 0 = 0 is always true. A division that has every number as its answer tells us nothing, so 0÷00 \div 0 has no answer either. That is why we say division by zero is undefined. (Division with remainder also needs b>0b > 0: no remainder rr could be smaller than 00.)

Formal mathematicsF

Gideon's precise statements

  1. "7×98=6867 \times 98 = 686." — True. 7×100−7×2=700−14=6867 \times 100 - 7 \times 2 = 700 - 14 = 686.
  2. "For every whole number nn, n×1=nn \times 1 = n." — True. nn groups of 11 make nn.
  3. "Multiplying always makes a number bigger." — False! 9×1=99 \times 1 = 9, which is not bigger than 99. One counterexample is enough to show that an "always" statement is false.
  4. "23÷523 \div 5 is 33 remainder 88." — False. 23=3×5+823 = 3 \times 5 + 8 is a true equation, but the rule says the remainder must be less than 55. Being precise about the rule matters.
  5. "Some number times 00 is 55." — False. Every number times 00 is 00.
For grown-ups · the same ideas in Lean, a proof checker

Lean is a computer program that checks proofs. Its whole numbers are called Nat. Each block below is a statement together with a proof that Lean has checked.

Calculating flexibly. The trick a×98=a×100−a×2a \times 98 = a \times 100 - a \times 2, proved for every aa from the distributive law, and the worked examples:

times_ninety_eightLean 4Proved here from basic factsFormally verified
/-- `a × 98 = a × 100 − a × 2` for every whole number `a`: since `100 = 98 + 2`, the
distributive law gives `a × 100 = a × 98 + a × 2`, and taking away `a × 2` leaves `a × 98`.
So `7 × 98 = 700 − 14 = 686`. -/
theorem times_ninety_eight (a : Nat) : a * 98 = a * 100 - a * 2 := by
  have h : a * 100 = a * 98 + a * 2 :=
    calc a * 100 = a * (98 + 2) := rfl
      _ = a * 98 + a * 2 := Nat.mul_add a 98 2
  rw [h, Nat.add_sub_cancel]
Axioms used: propextformal/Lumenary/WholeNumberArithmetic.leanTry it in the Lean web editor
seven_times_ninety_eightLean 4Proved here from basic factsFormally verified
/-- The worked example: `7 × 98 = 7 × 100 − 7 × 2 = 686`. Lean evaluates both sides. -/
theorem seven_times_ninety_eight : 7 * 98 = 7 * 100 - 7 * 2 ∧ 7 * 98 = 686 := by decide
Axioms used: No axiomsformal/Lumenary/WholeNumberArithmetic.leanTry it in the Lean web editor
twenty_five_times_thirty_sixLean 4Proved here from basic factsFormally verified
/-- `25 × 36 = 900`, by regrouping: `36 = 4 × 9`, and the associative law lets us multiply
`25 × 4 = 100` first. Each line of the `calc` block is one step of the mental calculation. -/
theorem twenty_five_times_thirty_six : 25 * 36 = 900 :=
  calc 25 * 36 = 25 * (4 * 9) := rfl
    _ = (25 * 4) * 9 := (Nat.mul_assoc 25 4 9).symm
    _ = 100 * 9 := rfl
    _ = 900 := rfl
Axioms used: propextformal/Lumenary/WholeNumberArithmetic.leanTry it in the Lean web editor
distrib_libraryLean 4Applies a library theoremFormally verified
/-- The distributive law `a × (b + c) = a × b + a × c`. This applies core Lean's
theorem `Nat.mul_add`. -/
theorem distrib_library (a b c : Nat) : a * (b + c) = a * b + a * c := Nat.mul_add a b c
Axioms used: No axiomsformal/Lumenary/WholeNumberArithmetic.leanTry it in the Lean web editor

Why the order of the factors does not matter. Lean defines multiplication as repeated addition: a×(b+1)=a×b+aa \times (b + 1) = a \times b + a. So for Lean, a×ba \times b means "bb copies of aa", the opposite reading from our "aa groups of bb". The commutative law says the two readings always agree. Lean proves it from the definition by induction: show it for 00, then show that if it holds for bb it holds for b+1b + 1.

zero_mul_from_definitionLean 4Proved here from basic factsFormally verified
/-- `0 × a = 0`: any number of copies of `0` add up to `0`. Proved by induction on `a`, using
only Lean's definition `n * (m + 1) = n * m + n`. -/
theorem zero_mul_from_definition (a : Nat) : 0 * a = 0 := by
  induction a with
  | zero => rfl
  | succ n ih => rw [Nat.mul_succ, ih]
Axioms used: No axiomsformal/Lumenary/WholeNumberArithmetic.leanTry it in the Lean web editor
succ_mul_from_definitionLean 4Proved here from basic factsFormally verified
/-- `(a + 1) × b = a × b + b`: making every one of the `b` copies one bigger adds `b` in all.
Proved by induction on `b` from the definition of multiplication. -/
theorem succ_mul_from_definition (a b : Nat) : (a + 1) * b = a * b + b := by
  induction b with
  | zero => rfl
  | succ n ih =>
    calc (a + 1) * (n + 1) = (a + 1) * n + (a + 1) := Nat.mul_succ (a + 1) n
      _ = a * n + n + (a + 1) := by rw [ih]
      _ = (a * n + a) + (n + 1) := by omega
      _ = a * (n + 1) + (n + 1) := by rw [Nat.mul_succ]
Axioms used: propext, Quot.soundformal/Lumenary/WholeNumberArithmetic.leanTry it in the Lean web editor
mul_comm_from_definitionLean 4Proved here from basic factsFormally verified
/-- The commutative law `a × b = b × a`, proved from the definition of multiplication as
repeated addition (by induction on `b`, with the two lemmas above). Lean's `a * b` means
"`b` copies of `a`", the opposite reading from "`a` groups of `b`"; this theorem is exactly why
the choice does not matter. -/
theorem mul_comm_from_definition (a b : Nat) : a * b = b * a := by
  induction b with
  | zero => rw [Nat.mul_zero, zero_mul_from_definition]
  | succ n ih => rw [Nat.mul_succ, ih, succ_mul_from_definition]
Axioms used: propext, Quot.soundformal/Lumenary/WholeNumberArithmetic.leanTry it in the Lean web editor

The same law is also in Lean's library. The first proof was done here; this one just uses the library's theorem:

mul_comm_libraryLean 4Applies a library theoremFormally verified
/-- The commutative law again, this time by applying core Lean's theorem `Nat.mul_comm`. -/
theorem mul_comm_library (a b : Nat) : a * b = b * a := Nat.mul_comm a b
Axioms used: No axiomsformal/Lumenary/WholeNumberArithmetic.leanTry it in the Lean web editor

The written method. The area model for any two-part numbers, then the example 23×4723 \times 47:

area_modelLean 4Proved here from basic factsFormally verified
/-- The area model: `(a + b) × (c + d)` is the sum of the four partial products. Split the
first factor (distributive law on the right), then split each part again (on the left). -/
theorem area_model (a b c d : Nat) :
    (a + b) * (c + d) = a * c + a * d + b * c + b * d :=
  calc (a + b) * (c + d) = a * (c + d) + b * (c + d) := Nat.add_mul a b (c + d)
    _ = (a * c + a * d) + (b * c + b * d) := by rw [Nat.mul_add a c d, Nat.mul_add b c d]
    _ = a * c + a * d + b * c + b * d := (Nat.add_assoc (a * c + a * d) (b * c) (b * d)).symm
Axioms used: propextformal/Lumenary/WholeNumberArithmetic.leanTry it in the Lean web editor
twenty_three_times_forty_sevenLean 4Proved here from basic factsFormally verified
/-- `23 × 47 = 1081`, as four partial products: `20 × 40 + 20 × 7 + 3 × 40 + 3 × 7`
`= 800 + 140 + 120 + 21`. The first step is `area_model` with `23 = 20 + 3` and `47 = 40 + 7`. -/
theorem twenty_three_times_forty_seven :
    23 * 47 = 20 * 40 + 20 * 7 + 3 * 40 + 3 * 7 ∧ 23 * 47 = 1081 :=
  ⟨area_model 20 3 40 7, rfl⟩
Axioms used: propextformal/Lumenary/WholeNumberArithmetic.leanTry it in the Lean web editor

Division with remainder. First Neema's eggs. Then the theorem: a quotient and remainder always exist, and they are unique. The existence proof adds eggs one at a time. Each new egg either fits in the unfinished tray, or it fills that tray and the leftover pile starts again at 00. The uniqueness proof is the "fence posts" argument.

eggs_in_traysLean 4Proved here from basic factsFormally verified
/-- 347 eggs fill 11 trays of 30, with 17 eggs left over: `347 = 11 × 30 + 17` and `17 < 30`.
Lean's `/` and `%` compute the same quotient and remainder. -/
theorem eggs_in_trays : 347 = 11 * 30 + 17 ∧ 17 < 30 ∧ 347 / 30 = 11 ∧ 347 % 30 = 17 := by
  decide
Axioms used: No axiomsformal/Lumenary/WholeNumberArithmetic.leanTry it in the Lean web editor
div_mod_existsLean 4Proved here from basic factsFormally verified
/-- Division with remainder always works: for `b > 0`, every `a` can be written as
`a = q × b + r` with `r < b`. The proof adds eggs one at a time (induction on `a`). Each new
egg either goes into the unfinished tray, or it completes that tray and the leftover pile
starts again at `0`. -/
theorem div_mod_exists (a b : Nat) (hb : 0 < b) : ∃ q r, a = q * b + r ∧ r < b := by
  induction a with
  | zero => exact ⟨0, 0, by rw [Nat.zero_mul], hb⟩
  | succ n ih =>
    obtain ⟨q, r, h, _hr⟩ := ih
    by_cases hfit : r + 1 < b
    · -- The new egg fits in the unfinished tray: the remainder grows by one.
      exact ⟨q, r + 1, by omega, hfit⟩
    · -- The new egg completes the tray (`r + 1 = b`): one more full tray, nothing left over.
      have hrb : r + 1 = b := by omega
      refine ⟨q + 1, 0, ?_, hb⟩
      calc n + 1 = q * b + (r + 1) := by omega
        _ = q * b + b := by rw [hrb]
        _ = (q + 1) * b + 0 := by rw [Nat.succ_mul, Nat.add_zero]
Axioms used: propext, Quot.soundformal/Lumenary/WholeNumberArithmetic.leanTry it in the Lean web editor
div_mod_uniqueLean 4Proved here from basic factsFormally verified
/-- The quotient and remainder are unique. If `q × b + r = q' × b + r'` with both remainders
less than `b`, then `q = q'` and `r = r'`. If `q` were smaller than `q'`, the right side
would be at least `(q + 1) × b = q × b + b`, which is more than `q × b + r`. -/
theorem div_mod_unique {b q r q' r' : Nat} (h : q * b + r = q' * b + r')
    (hr : r < b) (hr' : r' < b) : q = q' ∧ r = r' := by
  have hq : q = q' := by
    rcases Nat.lt_trichotomy q q' with hlt | heq | hgt
    · have hle : (q + 1) * b ≤ q' * b := Nat.mul_le_mul_right b hlt
      rw [Nat.succ_mul] at hle
      omega
    · exact heq
    · have hle : (q' + 1) * b ≤ q * b := Nat.mul_le_mul_right b hgt
      rw [Nat.succ_mul] at hle
      omega
  subst hq
  exact ⟨rfl, by omega⟩
Axioms used: propext, Quot.soundformal/Lumenary/WholeNumberArithmetic.leanTry it in the Lean web editor
div_mod_libraryLean 4Applies a library theoremFormally verified
/-- Lean's own quotient `a / b` and remainder `a % b` satisfy `a = (a / b) × b + a % b` with
`a % b < b`. This applies the core theorems `Nat.div_add_mod'` and `Nat.mod_lt`. -/
theorem div_mod_library (a b : Nat) (hb : 0 < b) : a = a / b * b + a % b ∧ a % b < b :=
  ⟨(Nat.div_add_mod' a b).symm, Nat.mod_lt a hb⟩
Axioms used: propextformal/Lumenary/WholeNumberArithmetic.leanTry it in the Lean web editor
long_division_953Lean 4Proved here from basic factsFormally verified
/-- The long division in the lesson: `953 ÷ 4` is `238` remainder `1`. -/
theorem long_division_953 : 953 = 238 * 4 + 1 ∧ 1 < 4 := by decide
Axioms used: No axiomsformal/Lumenary/WholeNumberArithmetic.leanTry it in the Lean web editor

Zero, and a counterexample.

no_division_by_zeroLean 4Proved here from basic factsFormally verified
/-- There is no answer to `5 ÷ 0`: no number `q` has `q × 0 = 5`, because `q × 0 = 0`. -/
theorem no_division_by_zero : ¬ ∃ q : Nat, q * 0 = 5 := by
  intro ⟨q, hq⟩
  rw [Nat.mul_zero] at hq
  -- `hq : 0 = 5`, which is false.
  exact absurd hq (by decide)
Axioms used: No axiomsformal/Lumenary/WholeNumberArithmetic.leanTry it in the Lean web editor
zero_div_zero_everyLean 4Applies a library theoremFormally verified
/-- And `0 ÷ 0` has no single answer: *every* `q` satisfies `q × 0 = 0`.
This applies core Lean's `Nat.mul_zero`. -/
theorem zero_div_zero_every (q : Nat) : q * 0 = 0 := Nat.mul_zero q
Axioms used: No axiomsformal/Lumenary/WholeNumberArithmetic.leanTry it in the Lean web editor
multiplying_need_not_enlargeLean 4Proved here from basic factsFormally verified
/-- "Multiplying always makes a number bigger" is false. One counterexample is enough:
`9 × 1 = 9` is not bigger than `9`. -/
theorem multiplying_need_not_enlarge : ¬ ∀ a b : Nat, a < a * b := by
  intro h
  have h91 : 9 < 9 * 1 := h 9 1
  exact absurd h91 (by decide)
Axioms used: No axiomsformal/Lumenary/WholeNumberArithmetic.leanTry it in the Lean web editor

What is not formalised here: Lean's whole numbers are not stored as rows of digits, so the column method and long division appear only through their key facts (the area model, and the long-division answer), not as digit-by-digit procedures. The Python experiment below runs the procedure digit by digit.

ComputationC

Margaret checks the methods

The column method for multiplication, step by stepPythonExhaustive finite checkExperimental evidenceComputationally tested
"""The written multiplication method, step by step, checked against Python.

The column method multiplies by one digit at a time, regrouping ("carrying")
ten ones as one ten, then adds the partial products shifted by place value.
The area model splits both numbers by place value and adds the same partial
products in a different grouping. We print the working for 47 x 23, compare
the digit-by-digit method with Python's built-in multiplication on every pair
of numbers below 200 and on random large pairs, and show what goes wrong when
the carries are forgotten.
"""

import random

def digits(n):
    """Digits of a whole number, ones first: digits(407) == [7, 0, 4]."""
    if n < 0:
        raise ValueError("whole numbers only")
    out = [n % 10]
    n //= 10
    while n:
        out.append(n % 10)
        n //= 10
    return out

def from_digits(ds):
    """Inverse of digits(): from_digits([7, 0, 4]) == 407."""
    return sum(d * 10 ** k for k, d in enumerate(ds))

def times_one_digit(a, d, carry_on=True):
    """Multiply a by a single digit d as in the column method.

    Returns (product, steps) where each step is (digit, digit*d + carry_in,
    written digit, carry_out). With carry_on=False the carries are dropped,
    which is the classic mistake.
    """
    if not 0 <= d <= 9:
        raise ValueError("d must be a single digit")
    carry, written, steps = 0, [], []
    for x in digits(a):
        total = x * d + carry
        new_carry = total // 10 if carry_on else 0
        written.append(total % 10)
        steps.append((x, total, total % 10, new_carry))
        carry = new_carry
    while carry:
        written.append(carry % 10)
        carry //= 10
    return from_digits(written), steps

def partial_products(a, b, carry_on=True):
    """The rows of the column method: a times each digit of b, shifted."""
    return [times_one_digit(a, d, carry_on)[0] * 10 ** k
            for k, d in enumerate(digits(b))]

def column_multiply(a, b, carry_on=True):
    """Multiply by the written column method."""
    return sum(partial_products(a, b, carry_on))

def area_pieces(a, b):
    """Area model: each non-zero place-value part of a times each part of b."""
    def parts(n):
        return [d * 10 ** k for k, d in enumerate(digits(n)) if d]
    return [(x, y, x * y) for x in parts(a)[::-1] for y in parts(b)[::-1]]

def count_mismatches(pairs, carry_on=True):
    """How many pairs (a, b) the column method gets wrong."""
    return sum(column_multiply(a, b, carry_on) != a * b for a, b in pairs)

def main():
    a, b = 47, 23
    print(f"Column method for {a} x {b}")
    product, steps = times_one_digit(a, 3)
    for x, total, write, carry in steps:
        print(f"  {x} x 3 + carry = {total}: write {write}, carry {carry}")
    rows = partial_products(a, b)
    print(f"  row 1: {a} x 3 = {rows[0]}")
    print(f"  row 2: {a} x 20 = {a} x 2 x 10 = {rows[1]}")
    print(f"  total: {rows[0]} + {rows[1]} = {sum(rows)}")
    pieces = area_pieces(a, b)
    print("Area model: " + ", ".join(f"{x} x {y} = {p}" for x, y, p in pieces))
    print("  " + " + ".join(str(p) for _, _, p in pieces)
          + f" = {sum(p for _, _, p in pieces)} (same pieces, regrouped)")
    print()
    small = [(x, y) for x in range(200) for y in range(200)]
    rng = random.Random(2024)
    big = [(rng.randrange(10 ** 5, 10 ** 6), rng.randrange(10 ** 3, 10 ** 4))
           for _ in range(2000)]
    print("Column method versus Python's built-in multiplication:")
    print(f"  all {len(small):,} pairs below 200: "
          f"{count_mismatches(small)} mismatches")
    print(f"  {len(big):,} random 6-digit x 4-digit pairs: "
          f"{count_mismatches(big)} mismatches")
    wrong = count_mismatches(small, carry_on=False)
    print("A broken method that forgets to carry:")
    print(f"  47 x 3 gives {column_multiply(47, 3, carry_on=False)}, not 141;"
          f" wrong on {wrong:,} of the {len(small):,} pairs")
    print()
    print("Epistemic status: the 40,000 small pairs are checked completely, so the")
    print("method is correct for those; the random pairs are evidence only. Why it")
    print("works for every pair is the lesson's argument: place value plus the")
    print("distributive law.")

if __name__ == "__main__":
    main()
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

Checking all 40,00040{,}000 pairs below 200200 is a complete check of those pairs, but there are infinitely many pairs of numbers. The area-model argument covers them all.

Exactly one quotient and remainderPythonExhaustive finite checkExact computationComputationally tested
"""Division with remainder: one quotient and one remainder, found by search.

For a = q x b + r there are many pairs (q, r) if r may be as large as we like,
but exactly one with 0 <= r < b. We find the answer for 347 eggs in trays of 30
by repeated subtraction, list every pair that would work without the rule
r < b, and then search exhaustively: for every a up to 500 and b from 1 to 12
there is exactly one pair with r < b, and it agrees with Python's divmod.
Finally we see that "5 divided by 0" has no candidate answer at all.
"""

def repeated_subtraction(a, b):
    """Take b away from a as often as possible; return (quotient, remainder)."""
    if b <= 0:
        raise ValueError("b must be positive")
    if a < 0:
        raise ValueError("a must be a whole number")
    q = 0
    while a >= b:
        a -= b
        q += 1
    return q, a

def all_pairs(a, b, small_remainder=True):
    """Every (q, r) of whole numbers with q*b + r == a (and r < b if asked)."""
    if b <= 0:
        raise ValueError("b must be positive")
    pairs = []
    for q in range(a // b + 1):
        r = a - q * b
        if r >= 0 and (r < b or not small_remainder):
            pairs.append((q, r))
    return pairs

def exhaustive_check(max_a, max_b):
    """Return (cases, all unique?, all agree with divmod?)."""
    cases, unique, agree = 0, True, True
    for a in range(max_a + 1):
        for b in range(1, max_b + 1):
            cases += 1
            pairs = all_pairs(a, b)
            unique = unique and len(pairs) == 1
            agree = agree and pairs == [divmod(a, b)]
    return cases, unique, agree

def solutions_of_times_zero(target, search_up_to):
    """All q in 0..search_up_to with q * 0 == target."""
    return [q for q in range(search_up_to + 1) if q * 0 == target]

def main():
    q, r = repeated_subtraction(347, 30)
    print(f"347 eggs, trays of 30: take away 30 a total of {q} times,"
          f" {r} eggs left.")
    print(f"  347 = {q} x 30 + {r}, and {r} < 30")
    loose = all_pairs(347, 30, small_remainder=False)
    shown = ", ".join(f"({a}, {b})" for a, b in loose[:4])
    print(f"Without the rule r < 30 there are {len(loose)} pairs (q, r):")
    print(f"  {shown}, ..., {loose[-1]}")
    print(f"With the rule r < 30 there is only {all_pairs(347, 30)}")
    print()
    cases, unique, agree = exhaustive_check(500, 12)
    print(f"Every a from 0 to 500 and b from 1 to 12 ({cases:,} cases):")
    print(f"  exactly one pair with r < b every time: {unique}")
    print(f"  that pair is Python's divmod(a, b) every time: {agree}")
    print()
    print("Dividing by zero: q x 0 = 5 for q in 0..1000? "
          f"{len(solutions_of_times_zero(5, 1000))} solutions.")
    print("  q x 0 = 0 for q in 0..1000? "
          f"{len(solutions_of_times_zero(0, 1000))} solutions: every q works.")
    print()
    print("Epistemic status: the search is complete for the 6,012 cases it")
    print("checks, so uniqueness is certain there and nowhere else. The lesson's")
    print("argument (multiples of b are b apart) proves it for every a and b > 0.")
    print("The zero search is evidence; q x 0 = 0 for every q is the proof.")

if __name__ == "__main__":
    main()
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.
Exercises

Your turn

Take your time. You can open a hint whenever you like.

1. Whole-number arithmetic

Warm-upHuman

Use the distributive law to work out 8×998 \times 99 in your head. (Hint: 99=100−199 = 100 - 1.)

2. Whole-number arithmetic

CoreHuman

Amina works out 4×17×254 \times 17 \times 25 like this: 4×17×25=17×(4×25)=17×100=17004 \times 17 \times 25 = 17 \times (4 \times 25) = 17 \times 100 = 1700. Which laws make her method correct?

Choose one

3. Whole-number arithmetic

CoreHuman

Use the area model to work out 36×2436 \times 24. Split 36=30+636 = 30 + 6 and 24=20+424 = 20 + 4, and add all four pieces.

4. Whole-number arithmetic

Warm-upHuman

Divide 100100 by 77. What is the remainder?

5. Whole-number arithmetic

CoreHuman

Kofi says 47÷8=447 \div 8 = 4 remainder 1515. He checks: 4×8+15=32+15=474 \times 8 + 15 = 32 + 15 = 47. Is his answer right?

Choose one

6. Whole-number arithmetic

CoreHuman

A farm has 10001000 eggs, and each tray holds 3030 eggs. How many trays are needed to hold all the eggs?

7. Whole-number arithmetic

Warm-upHuman

What is 6÷06 \div 0?

Choose one

8. Whole-number arithmetic

CoreHuman

Which of these products are not bigger than the first number? (Choose all that apply.)

Choose all that apply

9. Whole-number arithmetic

CoreFormal

In Lean, a / b is the quotient and a % b is the remainder when a is divided by b. Gideon wants to state precisely that the remainder is smaller than the number we divide by (for b > 0). Which statement says exactly that?

Choose one

10. Whole-number arithmetic

StretchComputational

Write a function divide(a, b) that finds the quotient and remainder by repeated subtraction: keep taking b away from a while at least b is left, counting how many times. Return the pair (q, r). You may assume a >= 0 and b > 0.

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.
Common misconceptionsH

Things that trip people up

Misconception

"Multiplying always makes a number bigger." Not always: 9×1=99 \times 1 = 9 and 9×0=09 \times 0 = 0. Later you will multiply by fractions such as 12\tfrac12, and then the answer is smaller: half of 99 is 4124\tfrac12.

Misconception

"The remainder can be any size." In 23÷523 \div 5, writing "33 remainder 88" is wrong even though 3×5+8=233 \times 5 + 8 = 23. The remainder must be less than the number you divide by. If it isn't, another full group fits.

Misconception

"Carrying is just a trick." Carrying is regrouping: ten ones are one ten, and ten tens are one hundred. When 7×3=217 \times 3 = 21 ones, the "carried 22" is 22 tens moving to the tens column.

Misconception

"5÷0=05 \div 0 = 0" or "5÷0=55 \div 0 = 5". Check by multiplying back: 0×0=00 \times 0 = 0 and 5×0=05 \times 0 = 0, never 55. No number works, so 5÷05 \div 0 has no answer.

Misconception

"Division is commutative too." It isn't: 12÷3=412 \div 3 = 4, but 3÷12=03 \div 12 = 0 remainder 33. Only addition and multiplication can be done in either order.

ViewpointsH

Other ways of seeing

Geometry— Multiplication is area and volume

A geometer sees a×ba \times b as the area of an aa by bb rectangle, and a×b×ca \times b \times c as the volume of a box. Then the laws become facts about shapes. The commutative law says that turning a rectangle through a right angle does not change its area. The distributive law says that cutting a rectangle into two pieces does not change the total area. The associative law says that a box has the same volume however you slice it. These pictures keep working long after whole numbers. Later you will use them for lengths that are fractions or decimals (area and perimeter).

Algebra— The laws are the real rules of the game

An algebraist notices that every clever calculation in this lesson used only a short list of laws. So anything that obeys those laws can be calculated with in the same way. For example, the area model works with letters: (x+3)×(x+7)=x×x+7x+3x+21(x + 3) \times (x + 7) = x \times x + 7x + 3x + 21. Many other number systems obey the same laws, and mathematicians give such a system a name: a ring (rings). The laws you learn in primary school are, word for word, part of its definition.

Number theory— Remainders are the start of number theory

Division with remainder is where number theory begins. Repeating it gives Euclid's algorithm for the greatest common factor. Keeping only the remainder gives "clock arithmetic", where 99 o'clock plus 55 hours is 22 o'clock because 14=1×12+214 = 1 \times 12 + 2. See factors and primes, clock arithmetic and Euclid's algorithm.

Wonder Trails

Wonder further

What time will it be 2929 hours from now? Remainders can answer that, and they lead to a whole new kind of arithmetic. This trail is optional.

Wonder Trail · Optional · never gradedClock arithmeticIt's 9 o'clock. What time will it be in 5 hours — and in 29 hours? Can a clock teach us a whole new kind of arithmetic?Follow the trail
Set-theoretic connectionH

Multiplying and dividing with sets

In the sets lesson you met the Cartesian product A×BA \times B, the set of all pairs (a,b)(a, b). If Juma has 33 shirts and 44 pairs of trousers, he can make 3×4=123 \times 4 = 12 outfits, one for each pair (shirt, trousers). In general, ∣A×B∣=∣A∣×∣B∣|A \times B| = |A| \times |B|. That is where the multiplication sign in A×BA \times B comes from.

Division with remainder sorts a set. Dividing 347347 eggs by 3030 splits the set of eggs into 1111 trays of 3030 and one leftover group of 1717. These groups do not overlap and together they contain every egg. A splitting like this is called a partition.

Category-theoretic connectionH

A first glimpse of structure

Think of "multiply by 33" as a machine that changes any number into three times that number. Feed its output into a "multiply by 44" machine, and the result is the same as one "multiply by 1212" machine. Chaining machines one after another is called composition (see one thing after another). The associative law says it does not matter how we bracket a chain of three machines. The machine "multiply by 11" changes nothing. These two rules — brackets don't matter, and there is a do-nothing machine — are the rules that define a category, an idea you can explore much later.

History & global context

History and global context

  • Egypt. The Rhind Mathematical Papyrus, copied by the scribe Ahmes around 1550 BCE from an older text, multiplies by doubling. To find 13×1213 \times 12: 12,24,48,9612, 24, 48, 96 are 1,2,4,81, 2, 4, 8 times 1212, and 13=1+4+813 = 1 + 4 + 8, so 13×12=12+48+96=15613 \times 12 = 12 + 48 + 96 = 156. This is the distributive law at work.
  • Mesopotamia. Babylonian scribes, around 1800 BCE, worked in base 6060. They kept tables of products and tables of reciprocals. To divide by a number, they multiplied by its reciprocal.
  • China. The Tsinghua bamboo slips, dated to about 305 BCE, contain a decimal multiplication table. It is the oldest one known anywhere in the world.
  • Greece. Euclid's Elements (around 300 BCE) finds the greatest common measure of two numbers by subtracting the smaller from the larger again and again. Division with remainder is hidden inside this method.
  • India and the Islamic world. Indian mathematicians developed decimal place value with a symbol for zero. Around 825 CE, Muḥammad ibn Mūsā al-Khwārizmī of Baghdad wrote a book on calculating with these "Hindu numerals". Its Latin translation spread the methods to Europe, and the word algorithm comes from his name.
  • Today. In her book Knowing and Teaching Elementary Mathematics (1999), Liping Ma compared primary-school teachers in China and the United States. Many of the Chinese teachers, though they had spent fewer years in school, explained the methods through place value and the laws. She called this a "profound understanding of fundamental mathematics".
Further reading

Further reading

  • Liping Ma, Knowing and Teaching Elementary Mathematics (1999). For teachers and parents; chapters 1–2 are about regrouping and multi-digit multiplication.
  • Hung-Hsi Wu, Understanding Numbers in Elementary School Mathematics (2011). A careful account of why the standard algorithms work.
  • Hans Magnus Enzensberger, The Number Devil (1997). A playful story about numbers for young readers.
  • George Gheverghese Joseph, The Crest of the Peacock: Non-European Roots of Mathematics (1991). The history of calculation around the world.