# Lecture 18: Strong induction, Euclid's algorithm

• writing a number in base b.
• strong induction
• divisibility
• Euclid's gcd algorithm.

## Strong induction

Note: weak induction is the technique that we called "induction" in previous lectures.

To prove a claim ∀ n ∈ N, P(n) using strong induction, you must:

1. prove P(0)
2. For an arbitrary n, prove P(n) while assuming P(0), P(1), ..., P(n − 1).

More formally, the inductive hypothesis for strong induction is ∀ k < n, P(k) whereas the inductive hypothesis for weak induction is P(n − 1).

Fact: strong induction is equivalent to weak induction: there is nothing you can prove using strong induction that you can't prove using weak induction.

## Writing a number in base b

Theorem: for any n ≥ 1 and b ≥ 2, you can write n in base b. That is, there are digits a0, a1, ..., ak such that (akak − 1. . . a2a1a0)b = n.

Note: as with the division algorithm, the proof of this theorem contains the algorithm used to construct the base-b representation.

Proof: by strong induction on n. In the base case, we can choose a0 = 1. Then since b > 1, b > a0, and n = a0 = (a0)b.

For the inductive step, assume that any number k < n can be written in base b. We wish to write n in base b. To do so, use Euclidean division to write n = qb + r. Let a0 = r. By the inductive hypothesis, we can write q in base b: q = (alʹal − 1ʹ. . . a2ʹa1ʹa0ʹ) (we have to check that q < n, but this is true).

It turns out that these digits of q are also the higher digits of n. That is, a1 = aʹ0 and a2 = aʹ1 and so on. To check this, we know:

q = ∑ i = 0laiʹbi

We also know that n = qb + r, so

n = qb + r = b(∑ i = 0laiʹbi) + r = a0 + ∑ i = 0laiʹbi + 1 = a0 + ∑ i = 0lai + 1bi + 1

By changing i to k − 1 in the summation this becomes

n = a0 + ∑ k = 1l + 1akbk = ∑ k = 0l + 1akbk

which shows that (ai) is the base b representation of n.

Note: it turns out base b representation is unique (just as quotient and remainder are), this is a good exercise.

## Divisibility

Definition: for two integers a and b, we say a divides b (written ab) if there exists some integer k such that ak = b.

## Euclid's algorithm to find the greatest common divisor

As a technical tool in the coming lectures, we will need to compute the greatest common divisor of two numbers. Here we write down the algorithm and the property that it needs to satisfy, we will prove that it does satisfy that property in the next lecture.

Given a ≥ 0 and b ≥ 0, Euclid's algorithm defines g(a, b) as follows:

• If b = 0, then g(a, b) is defined to be a.
• If b ≤ a, then g(a, b) is defined as follows: first, use Euclidean division to write a = qb + r. Then g(a, b) is defined to be g(b, r).
• If b > a, then g(a, b) is defined to be g(b, a).

Does this even define a function? It's not clear, because g is defined in terms of itself. For example, if I said "define f by f(x) = f(x), this doesn't actually define a function.

This is an example of an inductive (or recursive) definition. Notice that whenever we define g(a, b) in terms of g(x, y), y is always smaller than b. That means we can only possibly need to compute b other values of g before needing g(aʹ, 0) for some aʹ, and this is well defined.

## Properties of g

I claim that g computes the common divisor of a and b. What does this mean?

• g(a, b) must be a common divisor of a and b: g(a, b)∣a and g(a, b)∣b.
• g(a, b) must be bigger than all other common divisors: if ca and cb then g(a, b) ≥ c. We will in fact prove that cg(a, b) (which clearly can only happen if c ≤ g(a, b).