Division

Contents

Division#




Summary#

Integer Division

\( \boxed{ \forall a, b \in \mathbb{Z} \quad a \mid b \quad \iff \quad \exists c \in \mathbb{Z} \quad ac = b } \)

\( \boxed{ \forall a \in \mathbb{Z} \quad a \ne 0 \quad \implies \quad 0 \nmid a } \)

\( \boxed{ \forall a \in \mathbb{Z} \quad a \mid 0 } \)

\( \boxed{ \forall a \in \mathbb{Z} \quad a \mid \pm a } \)

\( \boxed{ \forall a \in \mathbb{Z} \quad \pm 1 \mid a } \)

\( \boxed{ \forall a, b \in \mathbb{Z} \quad ab = 1 \quad \iff \quad a = b = \pm 1 } \)

\( \boxed{ \forall a, b \in \mathbb{Z} \quad (a \mid b) \land (b \mid a) \quad \iff \quad a = \pm b } \)

\( \boxed{ \forall a, b \in \mathbb{Z} \quad \Big( \quad b \ne 0 \quad \land \quad a \mid b \quad \Big) \quad \implies \quad |a| \le |b| } \)

\( \boxed{ \forall a, b, c \in \mathbb{Z} \quad c \ne 0 \quad \implies \quad \Big( \quad ac = bc \iff a = b \quad \Big) } \)

\( \boxed{ \forall a, b, c \in \mathbb{Z} \quad c \ne 0 \quad \implies \quad \Big( \quad ac \mid bc \iff a \mid b \quad \Big) } \)

\( \boxed{ \forall a, b, c \in \mathbb{Z} \quad (a \mid b) \land (b \mid c) \quad \implies \quad a \mid c } \)

\( \boxed{ \forall a, b, c \in \mathbb{Z} \quad a \mid b \quad \implies \quad a \mid bc } \)

\( \boxed{ \forall a, b, c, x, y \in \mathbb{Z} \quad (a \mid b) \land (a \mid c) \quad \implies \quad a \mid (bx + cy) } \)

\( \boxed{ \begin{aligned} \forall a, b \in \mathbb{Z} \quad \text{Even}(a) \quad & \iff \quad \exists k \in \mathbb{Z} \quad a = 2k \\ \text{Odd}(a) \quad & \iff \quad \exists k \in \mathbb{Z} \quad a = 2k \pm 1 \\ \text{Even}(a \pm b) \quad & \iff \quad (\text{Even}(a) \land \text{Even}(b)) \oplus (\text{Odd}(a) \land \text{Odd}(b)) \\ \text{Odd}(a \pm b) \quad & \iff \quad (\text{Even}(a) \land \text{Odd}(b)) \oplus (\text{Odd}(a) \land \text{Even}(b)) \\ \text{Even}(ab) \quad & \iff \quad \text{Even}(a) \lor \text{Even}(b) \\ \text{Odd}(ab) \quad & \iff \quad \text{Odd}(a) \land \text{Odd}(b) \\ \end {aligned} } \)

\( \boxed{ \begin{aligned} \forall a \in \mathbb{Z} \quad \forall n \ge 1 \quad \text{Even}(a) \quad & \iff \quad \text{Even}(a^n) \\ \text{Odd}(a) \quad & \iff \quad \text{Odd}(a^n) \\ \end {aligned} } \)

\( \boxed{ \forall p, q \in \mathbb{Z} \quad \sqrt{2} \ne p/q } \)

\( \boxed{ \forall n \in \mathbb{Z} \quad \text{Odd}(n) \quad \iff \quad 8 \mid (n^2 - 1) } \)

\( \boxed{ \forall n \in \mathbb{Z} \quad \text{Odd}(n) \quad \iff \quad \exists k \in \mathbb{Z} \quad n = 4k \pm 1 } \)

\( \boxed{ \begin{aligned} \forall m, n \in \mathbb{Z} \quad & \exists k \in \mathbb{Z} \quad mn = 4k + 1 \quad \iff \quad \exists s, t \in \mathbb{Z} \quad \Big( \quad m = 4s + 1 \land n = 4t + 1 \quad \oplus \quad m = 4s - 1 \land n = 4t - 1 \quad \Big) \\ & \exists k \in \mathbb{Z} \quad mn = 4k - 1 \quad \iff \quad \exists s, t \in \mathbb{Z} \quad \Big( \quad m = 4s - 1 \land n = 4t + 1 \quad \oplus \quad m = 4s + 1 \land n = 4t - 1 \quad \Big) \\ \end {aligned} } \)

\( \boxed{ \begin{aligned} \forall m, n \in \mathbb{Z} \quad & \exists k \in \mathbb{Z} \quad mn = 6k + 1 \quad \iff \quad \exists s, t \in \mathbb{Z} \quad \Big( \quad m = 6s + 1 \land n = 6t + 1 \quad \oplus \quad m = 6s - 1 \land n = 6t - 1 \quad \Big) \\ & \exists k \in \mathbb{Z} \quad mn = 6k - 1 \quad \iff \quad \exists s, t \in \mathbb{Z} \quad \Big( \quad m = 6s - 1 \land n = 6t + 1 \quad \oplus \quad m = 6s + 1 \land n = 6t - 1 \quad \Big) \\ \end {aligned} } \)

GCD

\( \begin{aligned} & \gcd(a, b) \mid a \\ & \gcd(a, b) \mid b \\ & c \mid a \land c \mid b \implies c \mid \gcd(a, b) \\ & \gcd \left( \frac{a}{\gcd(a, b)}, \frac{b}{\gcd(a, b)} \right) = 1 \\ & \gcd(a + by, b) = \gcd(a, b) \\ \end {aligned} \)

Fundamental Theorem of Arithmetic

\( \begin{aligned} n &= p_1^{n_1} p_2^{n_2} \dots p_k^{n_k} &&= \prod_{i=1}^k p_i^{n_i} \\ \gcd(a, b) &= p_1^{\min(a_1, b_1)} p_2^{\min(a_2, b_2)} \dots p_k^{\min(a_k, b_k)} &&= \prod_{i=1}^k p_i^{\min(a_i, b_i)} \\ \text{lcm}(a, b) &= p_1^{\max(a_1, b_1)} p_2^{\max(a_2, b_2)} \dots p_k^{\max(a_k, b_k)} &&= \prod_{i=1}^k p_i^{\max(a_i, b_i)} = \frac{a \times b}{\gcd(a, b)} \\ a \times b &= p_1^{a_1 + b_1} p_2^{a_2 + b_2} \dots p_k^{a_k + b_k} &&= \prod_{i=1}^k p_i^{a_i + b_i} \\ \end {aligned} \)




Integer Division#

DIVISION

Let \(a\) and \(b\) be integers.

We say that \(a\) (evenly) divides \(b\) when there is an integer \(c\) such that \(ac = b\) (or equivalently if \(b/a\) is an integer) and we write

\(a \mid b\)

\( \boxed{ \forall a, b \in \mathbb{Z} \quad a \mid b \quad \iff \quad \exists c \in \mathbb{Z} \quad ac = b } \)

This is effectively equivalent to the requirement that \(b/a\) be an integer in which case \(a \ne 0\). This requirement is sometimes relaxed to allow for the possibility that \(0 \mid 0\). However, the number \(0/0\) remains undefined. More on this later.

We say that \(a\) is a divisor or factor of \(b\) and that \(b\) is a multiple of \(a\).

\( \underset{\text{divisor}}{\quad a \quad} \mid \underset{\text{multiple}}{\quad b \quad} \quad \quad \underset{\text{factors}}{\quad ac \quad} = \underset{\text{multiple}}{\quad b \quad} \)

\(\pm 1, \pm n\) are called the trivial divisors of \(n\). Otherwise a divisor \(d\) with \(1 \lt |d| \lt n\) is non-trivial or proper.

Although divisors may be negative, we usually only speak of positive divisors.

Example

List the divisors \(d\) of \(1\).

\( \begin{aligned} & & d \mid n && d & \times \phantom{-}k = n \\ \hline & \text{trivial} & -1 \mid 1 && -1 & \times -1 \\ & \text{trivial} & 1 \mid 1 && 1 & \times \phantom{-}1 \\ \end {aligned} \)

List the divisors \(d\) of \(6\).

\( \begin{aligned} & & d \mid n && d & \times \phantom{-}k = n \\ \hline & \text{trivial} & -6 \mid 6 && -6 & \times -1 \\ & & -3 \mid 6 && -3 & \times -2 \\ & & -2 \mid 6 && -2 & \times -3 \\ & \text{trivial} & -1 \mid 6 && -1 & \times -6 \\ & \text{trivial} & 1 \mid 6 && 1 & \times \phantom{-}6 \\ & & 2 \mid 6 && 2 & \times \phantom{-}3 \\ & & 3 \mid 6 && 3 & \times \phantom{-}2 \\ & \text{trivial} & 6 \mid 6 && 6 & \times \phantom{-}1 \\ \end {aligned} \)


Claim (zero division): zero divides no non-zero integer#

Claim

\(0\) divides no non-zero integer.

\( \boxed{ \begin{aligned} \forall a \in \mathbb{Z} \quad a \ne 0 \quad & \implies \quad 0 \nmid a \\ \forall a \in \mathbb{Z} \quad a = 0 \quad & \lor \quad 0 \nmid a \\ \lnot \exists a \in \mathbb{Z} \quad a \ne 0 \quad & \land \quad 0 \mid a \\ \end {aligned} } \)

Proof by contradiction

Let \(a\) be a non-zero integer and suppose

\(0 \mid a \quad \iff \quad 0k = a\) for some integer \(k\).

But no integer \(k\) satisfies this equation for non-zero \(a\). In other words, the LHS is \(0\) and the RHS is non-zero regardless of the value of \(k\).

Contradiction! Thus \(0 \nmid a\).

\(\blacksquare\)

How about \(0 \mid 0\)? See the next claim.


Claim: every integer “integer-divides” \(0\)#

Claim

Every integer “integer-divides” \(0\).

\( \boxed{ \forall a \in \mathbb{Z} \quad a \mid 0 } \)

Proof

Let \(a\) be an integer. There are two cases.

If \(a \ne 0\) then \(a \mid 0\) since there is an integer \(k\) such that \(ak = 0\), namely \(0\) itself.

If \(a = 0\) then \(0 \mid 0\) since any integer \(k\) satisfies the equation \(0k = 0\).

In other words

\(a \mid 0 \quad \iff \quad 0a = 0\)

for any integer \(a\).

\(\blacksquare\)

The integer \(0\) modulo \(a\) is trivially congruent to \(0\).

\( a \mid 0 \iff a \times k = 0 - 0 \iff 0 \equiv 0 \mod a \)


Claim: every integer divides itself#

Claim

Every integer \(a\) and its additive inverse \(-a\) divides itself.

\( \boxed{ \forall a \in \mathbb{Z} \quad \pm a \mid a } \)

This is to say that every integer \(a\) divides both itself and its additive inverse \(-a\).

\( \boxed{ \forall a \in \mathbb{Z} \quad a \mid \pm a } \)

Proof

Let \(a\) be an integer.

\(\phantom{-}a \mid \phantom{-}a\) since there is an integer \(k\) such that \(\phantom{-}ak = \phantom{-}a\), namely \(\phantom{-}1\).

\( -a \mid \phantom{-}a\) since there is an integer \(k\) such that \(-ak = \phantom{-}a\), namely \(-1\).

\( \phantom{-}a \mid -a\) since there is an integer \(k\) such that \(\phantom{-}ak = -a\), namely \(-1\).

\(\blacksquare\)

An integer \(a\) modulo \(a\) is always congruent to \(0\).

\( a \mid a \iff a \times k = a - 0 \iff a \equiv 0 \mod a \)


Claim: \(\pm 1\) divide every integer#

Claim

\(\pm 1\) divide every integer.

\( \boxed{ \forall a \in \mathbb{Z} \quad \pm 1 \mid a } \)

Proof

Let \(a\) be an integer.

\(\phantom{-}1 \mid a\) since there is an integer \(k\) such that \(\phantom{-}1 \times k = a\), namely \(\phantom{-}a\) itself.

\( -1 \mid a\) since there is an integer \(k\) such that \( -1 \times k = a\), namely \(-a\).

In the case of \(-1 \mid 0 \iff -1 \times -0 = 0\) we say that \(-0\) is just another way to write \(0\).

\(\blacksquare\)

An integer \(a\) modulo \(1\) is always congruent to \(0\).

\( 1 \mid a \iff 1 \times k = a - 0 \iff a \equiv 0 \mod 1 \)


Claim: the product of two integers is one iff both are one or negative one#

Claim

Let \(a\) and \(b\) be integers.

\(ab = 1\) iff \(a = b = \pm 1\).

\( \boxed{ \forall a, b \in \mathbb{Z} \quad ab = 1 \quad \iff \quad a = b = \pm 1 } \)

Proof

First Direction

Suppose \(ab = 1\).

Then it is the case that both \(a \mid 1\) and \(b \mid 1\).

The only divisors of \(1\) are \(\pm 1\).

If \(a = \phantom{-}1\) then \(1 = \phantom{(-)}ab = \phantom{-}b\).

If \(a = -1\) then \(1 = (-1)b = -b\).

Second Direction

Suppose \(a = b = \pm 1\).

Then \(ab = 1 \times 1 = 1 = (-1) \times (-1)\).

\(\blacksquare\)


Claim: two integers divide each other iff they are equal up to sign#

Claim

Let \(a\) and \(b\) be integers.

Both \(a \mid b\) and \(b \mid a\) iff \(a = \pm b\).

\( \boxed{ \forall a, b \in \mathbb{Z} \quad (a \mid b) \land (b \mid a) \quad \iff \quad a = \pm b } \)

Proof

First Direction

Suppose \(a \mid b\) and \(b \mid a\). Then there are integers \(m\) and \(n\) such that \(b = am\) and

\( \begin{aligned} a = bn = (am)n = a(mn) \quad & \iff \quad 1 = mn \\ & \iff \quad m = n = \pm 1 \\ \end {aligned} \)

Suppose \(m = n = \phantom{-}1\). Then \(a = \phantom{-}b\).

Suppose \(m = n = -1\). Then \(a = -b\).

Second Direction

Suppose \(a = \phantom{-}b\).

\(a \times 1 = \phantom{-}b \times 1 \quad \iff \quad (a \mid b) \land (b \mid a)\).

Suppose \(a = -b\).

\( \begin{aligned} a \times 1 = -b \times 1 \quad & \iff \quad a \times \underset{k}{-1} = b \times 1 \quad \iff \quad a \mid b \\ \quad & \iff \quad a \times 1 = b \times \underset{k}{-1} \quad \iff \quad b \mid a \\ \end {aligned} \)

\(\blacksquare\)


Claim: \(a \mid b \implies |a| \le |b|\)#

Claim

Let \(a\) and \(b\) be integers with \(b \ne 0\).

If \(a \mid b\) then \(|a| \le |b|\).

\( \boxed{ \forall a, b \in \mathbb{Z} \quad \Big( \quad b \ne 0 \quad \land \quad a \mid b \quad \Big) \quad \implies \quad |a| \le |b| } \)

Proof

Suppose \(a \mid b\) with \(b \ne 0\). Then there is an integer \(k\) such that \(ak = b\).

\(ak = b \implies |ak| = |b| = |a||k| = |b|\)

We know that the absolute value is positive definite

\(b \ne 0 \iff |b| \ne 0\)

Then \(0 \ne |b| = |a||k|\) requires that \(|a| \ge 1\) and \(|k| \ge 1\) and so

\(1 \le |a| \iff |k| \le |a||k| = |b|\)

\(1 \le |k| \iff |a| \le |a||k| = |b|\)

\(\blacksquare\)


Claim: \(ac = bc \iff a = b\)#

Claim

Let \(a\), \(b\), and \(c\) be integers with \(c \ne 0\).

\(ca = cb\) iff \(a = b\).

\( \boxed{ \forall a, b, c \in \mathbb{Z} \quad c \ne 0 \quad \implies \quad \Big( \quad ac = bc \quad \iff \quad a = b \quad \Big) } \)

Proof

First Direction

It must be shown that if \(ac = bc\) then \(a = b\).

Suppose \(ac = bc\) with \(c \ne 0\).

\(ac/c = bc/c \quad \iff \quad a = b\)

And with \(c = 0\).

\( \begin{aligned} &a0 = 0 = b0 \iff (a = b \lor a \ne b) \\ &a0 = 0 = b0 \quad \;\not\!\!\!\!\implies \quad a = b \\ \end {aligned} \)

In other words, if we allowed \(c = 0\) then \(a\) would not have to equal \(b\).

Second Direction

It must be shown that if \(a = b\) then \(ac = bc\).

Suppose \(a = b\).

\(a = b \quad \iff \quad ac = bc\) for any \(c\), including \(c = 0\).

\(\blacksquare\)


Claim: \(ac \mid bc \iff a \mid b\)#

Claim

Let \(a\), \(b\), and \(c\) be integers with \(c \ne 0\).

\(ac \mid bc\) iff \(a \mid b\).

\( \boxed{ \forall a, b, c \in \mathbb{Z} \quad c \ne 0 \quad \implies \quad \Big( \quad ac \mid bc \quad \iff \quad a \mid b \quad \Big) } \)

Proof

First Direction

Suppose \(ac \mid bc\) with \(c \ne 0\). Then there is an integer \(k\) such that \(ack/c = bc/c \iff ak = b \iff a \mid b\).

Another way to view this is that

\(ack = bc \iff ack - bc = 0 \iff c(ak - b) = 0 \iff c = 0 \lor ak - b = 0\)

\(c \ne 0 \implies ak - b = 0 \iff ak = b\)

And with \(c = 0\)

\( \begin{aligned} &a0k = 0 = b0 \iff (a \mid 0 \land b \mid 0) \\ &a0k = 0 = b0 \quad \;\not\!\!\!\!\implies \quad a \mid b \\ \end {aligned} \)

Another way to view this is what to do with \(0/0\) in the following equation?

\(a0k/0 = b0/0 \quad \iff \quad (0/0) \times ak = (0/0) \times b\)

Although \(0 \mid 0\) because \(0\) is a divisor (multiple) of \(0\), the number \(0/0\) is undefined (i.e., \(0/0\) is not equal to \(0\), \(1\), or any other number).

Second Direction

Suppose \(a \mid b\). Then there is an integer \(k\) such that \(ak = b \iff (ac)k = (bc) \iff ac \mid bc\) for any integer \(c\), including \(c = 0\).

\(\blacksquare\)


Claim: \((a \mid b) \land (b \mid c) \implies a \mid c\)#

Claim

Let \(a\), \(b\), and \(c\) be integers.

If \(a \mid b\) and \(b \mid c\) then \(a \mid c\).

\( \boxed{ \forall a, b, c \in \mathbb{Z} \quad (a \mid b) \land (b \mid c) \quad \implies \quad a \mid c } \)

Proof

Suppose \(a \mid b\) and \(b \mid c\). Then there are integers \(d\) and \(e\) such that \(b = ad\) and

\(c = be = (ad)e = a(de)\)

\(\blacksquare\)

Generalization to \(k \ge 2\) integers.

\( \begin{aligned} \forall a_i \in \mathbb{Z} \quad \bigwedge_{i=2}^k a_{i-1} \mid a_i \quad \implies \quad a_1 \mid a_k \end {aligned} \)


Claim: \(a \mid b \implies a \mid bc\)#

Claim

Let \(a\), \(b\), and \(c\) be integers.

If \(a \mid b\) then \(a \mid bc\).

\( \boxed{ \forall a, b, c \in \mathbb{Z} \quad a \mid b \quad \implies \quad a \mid bc } \)

Proof

Suppose \(a \mid b\). Then there is an integer \(k\) such that \(ak = b \implies a(ck) = (bc) \implies a \mid bc\).

\(\blacksquare\)

The converse statement does not hold. In other words, if \(a \mid bc\) then it may be the case that neither does \(a \mid b\) nor does \(a \mid c\). For example, if \(a = 4\), \(b = 6\), and \(c = 10\) then

\(4 \mid 6 \times 10 \iff 4 \times 15 = 6 \times 10\) but \(4 \nmid 6\) and \(4 \nmid 10\).

Claim

\(a \mid b \implies a \mid b^n\) for any \(n \ge 1\)

Proof

Suppose \(a \mid b\). Then

\(a \mid b \iff ak = b \iff (ak)^n = b^n \iff a(a^{n-1}k^n) = b^n \iff a \mid b^n\)

\(\blacksquare\)

The converse statement does not hold in general. For example

\(4 \mid 2^2\) but \(4 \nmid 2\)


Claim: \((a \mid b) \land (a \mid c) \implies a \mid (bx + cy)\)#

Claim

Let \(a\), \(b\), \(c\), \(x\), \(y\) be integers.

If \(a \mid b\) and \(a \mid c\) then \(a \mid (bx + cy)\).

\( \boxed{ \forall a, b, c, x, y \in \mathbb{Z} \quad (a \mid b) \land (a \mid c) \quad \implies \quad a \mid (bx + cy) } \)

Proof

Suppose \(a \mid b\) and \(a \mid c\). Then there are integers \(m\) and \(n\) such that \(am = b\) and \(an = c\).

\( \begin{aligned} b + c &= am + an = a(m + n) &&\implies a \mid (b + c) \\ bx + cy &= amx + any = a(mx + ny) &&\implies a \mid (bx + cy) \\ \end {aligned} \)

\(\blacksquare\)

Generalization to \(k \ge 2\) integers.

\( \begin{aligned} \forall a, b_i, x_i \quad \bigwedge_{i=1}^k a \mid b_i \quad \implies \quad a \Bigm\vert \sum_{i=1}^k b_i x_i \end {aligned} \)


Even#

EVEN

An integer \(n\) is called even if there is an integer \(k\) such that

\(2k = n \quad \iff \quad 2 \mid n\)

In other words an integer is called even if \(2\) divides it.

\( \boxed{ \forall n \in \mathbb{Z} \quad \text{Even}(n) \quad \iff \quad \exists k \in \mathbb{Z} \quad n = 2k } \)

Odd#

ODD

An integer is called odd if it is not even.

In other words an integer \(n\) is called odd if there is an integer \(k\) such that

\(2k = n \pm 1 \quad \iff \quad 2 \mid (n \pm 1)\)

\( \boxed{ \forall n \in \mathbb{Z} \quad \text{Odd}(n) \quad \iff \quad \exists k \in \mathbb{Z} \quad n = 2k \pm 1 } \)

\( \begin{aligned} \forall n \in \mathbb{Z} \,\, [ \,\, \text{Odd}(n) &\iff \exists k \in \mathbb{Z} \,\, (n = 2k + 1) \\ &\iff \lnot \text{Even}(n) \\ &\iff \lnot\exists k \in \mathbb{Z} \,\, (n = 2k) \\ &\iff \forall k \in \mathbb{Z} \,\, (n \ne 2k) \,\, ] \\ \end{aligned} \)


Claim: an integer is even (odd) iff one more and one less than it is odd (even)#

Claim

An integer is even (odd) iff one more and one less than it is odd (even).

\( \boxed{ \begin{aligned} \forall a \in \mathbb{Z} \quad \text{Even}(a) \quad & \iff \quad \text{Odd}(a \pm 1) \\ \lnot\text{Even}(a) \quad & \iff \quad \lnot\text{Odd}(a \pm 1) \\ \text{Odd}(a) \quad & \iff \quad \text{Even}(a \pm 1) \\ \end {aligned} } \)

Proof

First Direction

It must be shown that if \(a\) is even then \(a \pm 1\) is odd.

Suppose \(a\) is even so that there is an integer \(k\) such that \(2k = a\). Then

\(a \pm 1 = 2k \pm 1\)

Second Direction

It must be shown that if \(a \pm 1\) is odd then \(a\) is even. This is equivalent to the contrapositive, that if \(a\) is odd then \(a \pm 1\) is even.

Suppose \(a\) is odd so that there is an integer \(k\) such that \(2k \pm 1 = a\). Then

\(a \pm 1 = 2k \pm 1 \pm 1 = 2k (\pm 2) = 2k'\) where \(k'\) is one of \(k - 1, k, k + 1\).

\(\blacksquare\)


Claim: the sum or difference of two even integers is even#

Claim

\(\text{even} \pm \text{even} = \text{even}\)

\( \boxed{ \forall a, b \in \mathbb{Z} \quad \text{Even}(a) \land \text{Even}(b) \quad \implies \quad \text{Even}(a \pm b) } \)

Proof

Suppose \(a\) and \(b\) are even integers. Then there are integers \(m\) and \(n\) such that \(a = 2m\) and \(b = 2n\).

\(a + b = 2m + 2n = 2(m + n)\)

\(\blacksquare\)

The converse statement is not encessarily true. For example

\(2 \mid (1 + 3)\) but \(2 \nmid 1\) and \(2 \nmid 3\)


Claim: the sum or difference of two odd integers is even#

Claim

\(\text{odd} \pm \text{odd} = \text{even}\)

\( \boxed{ \forall a, b \in \mathbb{Z} \quad \text{Odd}(a) \land \text{Odd}(b) \quad \implies \quad \text{Even}(a \pm b) } \)

Proof

Suppose \(a\) and \(b\) are odd integers. Then there are integers \(m\) and \(n\) such that \(a = 2m + 1\) and \(b = 2n + 1\).

\(a + b = 2m + 1 + 2n + 1 = 2(m + n + 1)\)

\(\blacksquare\)

The converse statement is not encessarily true. For example

\(2 \mid (4 + 6)\) but \(2 \nmid (4 \pm 1)\) and \(2 \nmid (6 \pm 1)\)


Claim: the sum or difference of an even integer and an odd integer is odd#

Claim

\(\text{even} \pm \text{odd} = \text{odd}\)

\( \boxed{ \forall a, b \in \mathbb{Z} \quad (\text{Even}(a) \land \text{Odd}(b)) \oplus (\text{Odd}(a) \land \text{Even}(b)) \quad \iff \quad \text{Odd}(a \pm b) } \)

Proof

First Direction

Suppose \(a\) is even and \(b\) is odd. Then there are integers \(m\) and \(n\) such that \(a = 2m\) and \(b = 2n + 1\).

\(a + b = 2m + 2n + 1 = 2(m + n) + 1\)

Second Direction

Suppose

\(2 \mid (a \pm b \pm 1)\)

Then

\(2k = a \pm b \pm 1\)

If \(a\) is even then \(b\) is odd.

\(2k = 2k' \pm b \pm 1 \iff \pm b = 2k - 2k' \mp 1 = 2(k - k') \pm 1\)

If \(a\) is odd then \(b\) is even.

\(2k = (2k' \pm 1) \pm b \pm 1 \iff \pm b = 2k - 2k' \mp 2 = 2(k - k' \pm 1)\)

\(\blacksquare\)

Claim

\(2k \pm (2k' \pm 1)\) for any integers \(k\) and \(k'\) is odd. In other words, \(2k\) plus or minus any odd integer is an odd integer.

\( \begin{aligned} 2p + (2r + 1) &= 2p + 2r + 1 & = 2(p + r) + 1 \\ 2p - (2r + 1) &= 2(q + 1) - 2r - 1 &= 2q + 2 - 2r - 1 = 2(q - r) + 1 \\ 2p + (2r - 1) &= 2(q + 1) + 2r - 1 &= 2q + 2 + 2r - 1 = 2(q + r) + 1 \\ 2p - (2r - 1) &= 2p - 2r + 1 & = 2(p - r) + 1 \\ \end {aligned} \)

\( \begin{aligned} 2k + 1 & \\ 2k - 1 &= 2(k' + 1) - 1 = 2k' + 2 - 1 = 2k' + 1 \\ 2k + 3 &= 2(k' - 1) + 3 = 2k' - 2 + 3 = 2k' + 1 \\ 2k - 3 &= 2(k' + 2) - 3 = 2k' + 4 - 3 = 2k' + 1 \\ 2k + 5 &= 2(k' - 2) + 5 = 2k' - 4 + 5 = 2k' + 1 \\ 2k - 5 &= 2(k' + 3) - 5 = 2k' + 6 - 5 = 2k' + 1 \\ \vdots \end {aligned} \)


Claim: the product of an even integer and any integer is even#

Claim

\(\text{even} \times (\text{even}, \text{odd}) = \text{even}\)

\( \boxed{ \forall a, b \in \mathbb{Z} \quad \text{Even}(a) \lor \text{Even}(b) \quad \iff \quad \text{Even}(ab) } \)

Proof

First Direction

\( \boxed{ \forall a, b \in \mathbb{Z} \quad \text{Even}(a) \lor \text{Even}(b) \quad \implies \quad \text{Even}(ab) } \)

We must show that if \(a\) or \(b\) is even then \(ab\) is even.

Let \(a\) be even (\(b\) by symmetry) so that there is an integer \(m\) such that \(a = 2m\).

Suppose \(b\) is even. Then there is an integer \(n\) such that \(b = 2n\) and

\(ab = 2m \times 2n = 2(2mn)\)

Suppose \(b\) is odd. Then there is an integer \(n\) such that \(b = 2n + 1\) and

\(ab = 2m(2n + 1) = 4mn + 2m = 2(2mn + m)\)

Second Direction

\( \boxed{ \begin{aligned} \forall a, b \in \mathbb{Z} \quad \text{Even}(ab) &\implies \text{Even}(a) \lor \text{Even}(b) \\ \lnot(\text{Even}(a) \lor \text{Even}(b)) &\implies \lnot\text{Even}(ab) \\ \lnot\text{Even}(a) \land \lnot\text{Even}(b) &\implies \lnot\text{Even}(ab) \\ \text{Odd}(a) \land \text{Odd}(b) &\implies \text{Odd}(ab) \\ \end {aligned} } \)

It must be shown that if \(ab\) is even then \(a\) or \(b\) is even.

This is equivalent to the contrapositive, if both \(a\) and \(b\) are odd then \(ab\) is odd, which is shown next.

\(\blacksquare\)


Claim: the product of two odd integers is odd#

Claim

\(\text{odd} \times \text{odd} = \text{odd}\)

\( \boxed{ \forall a, b \in \mathbb{Z} \quad \text{Odd}(a) \land \text{Odd}(b) \quad \iff \quad \text{Odd}(ab) } \)

Proof

First Direction

\( \boxed{ \forall a, b \in \mathbb{Z} \quad \text{Odd}(a) \land \text{Odd}(b) \quad \implies \quad \text{Odd}(ab) } \)

Suppose \(a\) and \(b\) are odd. Then there are integers \(m\) and \(n\) such that \(a = 2m + 1\) and \(b = 2n + 1\).

\(ab = (2m + 1)(2n + 1) = 4mn + 2m + 2n + 1 = 2(2mn + m + n) + 1\)

Second Direction

\( \boxed{ \begin{aligned} \forall a, b \in \mathbb{Z} \quad \text{Odd}(ab) &\implies \text{Odd}(a) \land \text{Odd}(b) \\ \lnot(\text{Odd}(a) \land \text{Odd}(b)) &\implies \lnot\text{Odd}(ab) \\ \lnot\text{Odd}(a) \lor \lnot\text{Odd}(b) &\implies \lnot\text{Odd}(ab) \\ \text{Even}(a) \lor \text{Even}(b) &\implies \text{Even}(ab) \\ \end {aligned} } \)

It must be shown that if \(ab\) is odd then both \(a\) and \(b\) are odd.

This is equivalent to the contrapositive, if either \(a\) or \(b\) is even then \(ab\) is even, which was shown previously.

\(\blacksquare\)


Claim: an integer and its square (\(n\)-th power) have the same parity#

Claim

An integer is even (odd) iff its square is even (odd).

\( \boxed{ \begin{aligned} \forall a \in \mathbb{Z} \quad \text{Even}(a) \quad & \iff \quad \text{Even}(a^2) \\ \lnot\text{Even}(a) \quad & \iff \quad \lnot\text{Even}(a^2) \\ \text{Odd}(a) \quad & \iff \quad \text{Odd}(a^2) \\ \end {aligned} } \)

Proof

First Direction

Suppose \(a\) is even. The product of two even integers is even.

Suppose \(a\) is odd. The product of two odd integers is odd.

Second Direction

Suppose \(a^2\) is even. Then there is an integer \(k\) such that \(2k = a^2\).

If \(a\) is odd then the LHS is even while the RHS is odd. Contradiction. Thus \(a\) must be even.

On the other hand suppose \(a^2\) is odd. Then there is an integer \(k\) such that \(2k \pm 1 = a^2\).

If \(a\) is even then the LHS is odd while the RHS is even. Contradiction. Thus \(a\) must be odd.

\(\blacksquare\)

The rest just is just a rehashing of what was already proved above for products of integers.

Suppose \(a\) is even so that there is an integer \(k\) such that \(2k = a\). Then

\(a^2 = (2k)^2 = 2(2k^2)\)

Suppose \(a\) is odd so that there is an integer \(k\) such that \(2k \pm 1 = a\). Then

\(a^2 = (2k \pm 1)^2 = 4k^2 (\pm 4k) \pm 1 = 2(2k^2 (\pm 2k)) \pm 1\)

This result generalizes to any \(n\)-th power with \(n \ge 1\).

\( \boxed{ \begin{aligned} \forall a \in \mathbb{Z} \quad \forall n \ge 1 \quad \text{Even}(a) \quad & \iff \quad \text{Even}(a^n) \\ \lnot\text{Even}(a) \quad & \iff \quad \lnot\text{Even}(a^n) \\ \text{Odd}(a) \quad & \iff \quad \text{Odd}(a^n) \\ \end {aligned} } \)


Claim: \(n\) is odd iff \(8 \mid (n^2 - 1)\)#

Claim

\(n\) is odd iff \(8 \mid (n^2 - 1)\).

\( \boxed{ \forall n \in \mathbb{Z} \quad \text{Odd}(n) \quad \iff \quad 8 \mid (n^2 - 1) } \)

Proof

First Direction

Suppose \(n = 2k + 1\) for some integer \(k\). Then

\( \begin{aligned} n &= 2k + 1 \\ n^2 &= (2k + 1)^2 = 4k^2 + 4k + 1 \\ n^2 - 1 &= 4k^2 + 4k = \textcolor{#0096FF}{4k(k + 1)} = (n - 1)(n + 1) \end {aligned} \)

Alternatively

\( \begin{aligned} n &= 2(k - 1) + 1 = 2k - 1 \\ n^2 &= (2k - 1)^2 = 4k^2 - 4k + 1 \\ n^2 - 1 &= 4k^2 - 4k = \textcolor{#0096FF}{4k(k - 1)} = (n - 1)(n + 1) \end {aligned} \)

Notice that since \(n\) is odd both \(n - 1\) and \(n + 1\) are even. \(n - 1 = 2s\) and \(n + 1 = 2s + 2\) for some integer \(s\) and so

\((n - 1)(n + 1) = 2s(2s + 2) = 4s^2 + 4s = \textcolor{#0096FF}{4s(s + 1)}\)

which is exactly what we found.

\(k\) (or \(s\)) is either even or odd. This is to say that one of \(k\) and \(k + 1\) is even and the other is odd and so their product is even so that

\(k(k + 1) = 2m\) for some integer \(m\).

\(n^2 - 1 = 4k(k + 1) = 4(2m) = 8m \quad \iff \quad 8 \mid n^2 - 1\)

Another way to view this is by checking cases.

If \(k\) is even then \(8 \mid 4k\)

If \(k\) is odd then \(k - 1\) is even and \(8 \mid 4(k - 1)\)

We know that if \(a \mid b\) then \(a \mid bc\). So whether \(k\) is even or odd, \(8\) divides a factor of \(n^2 - 1\) and so divides it.

Second Direction

Suppose \(8 \mid (n^2 - 1)\) for some \(n\). Then

\(8k + 1 = n^2\) for some integer \(k\).

If \(n\) is even then the RHS is even while the LHS is odd no matter the parity of \(k\). Contradiction.

Thus \(n\) must be odd.

\(\blacksquare\)


UNDER CONSTRUCTION

Proof by induction on \(n\)

It suffices to show that

\( \boxed{ \begin{aligned} & P(1) \quad \land \quad \forall n \ge 2 \quad \left( \bigwedge_{i=1}^{n-1} \right) \implies P(n) \\ & \text{where} \quad P(i) : \quad \exists k \in \mathbb{Z} \quad i = 2k + 1 \quad \implies \quad 8 \mid (i^2 - 1) \end {aligned} } \)

Base Case \(n = 1\)

\(8 \mid 0\)

Inductive Step

Suppose it is the case that \(8 \mid (n^2 - 1)\). It must be shown that it holds for the next odd number \(n + 2\).

\((n + 2)^2 - 1 = n^2 + 4n + 4 - 1 = n^2 - 1 + 4(n + 1)\)

We know that \(8 \mid (n^2 - 1)\) so we only need to check that \(8 \mid 4(n + 1)\).

Since \(n\) is odd \(n + 1\) is even so that \(n + 1 = 2k\) for some integer \(k\).

Thus \(8 \mid 4(n + 1) = 4(2k) = 8k\).

\(\blacksquare\)

Example

\( \begin{array}{r|rrrl} n && n^2 - 1 = 8 & \times & k \\ \hline 1 && 0 = 8 & \times & \phantom{1}0 \\ 3 && 8 = 8 & \times & \phantom{1}1 = 1 \\ 5 && 24 = 8 & \times & \phantom{1}3 = 1 + 2 \\ 7 && 48 = 8 & \times & \phantom{1}6 = 1 + 2 + 3 \\ 9 && 80 = 8 & \times & 10 = 1 + 2 + 3 + 4 \\ 11 && 120 = 8 & \times & 15 = 1 + 2 + 3 + 4 + 5 \\ \end {array} \)


Claim: every odd integer has the form \(4k \pm 1\)#

Claim

Every odd integer has the form \(4k \pm 1\).

\( \boxed{ \forall n \in \mathbb{Z} \quad \text{Odd}(n) \quad \iff \quad \exists k \in \mathbb{Z} \quad n = 4k \pm 1 } \)

Proof

Suppose \(n\) is odd so that \(n = 2k + 1\) for some integer \(k\).

If \(k\) is even then \(k = 2s\) for some integer \(s\) and \(n = 2(2s) + 1 = 4s + 1\).

If \(k\) is odd then \(k = 2t + 1\) for some integer \(t\) and \(n = 2(2t + 1) + 1 = 4t + 3 = 4(t + 1) - 1\).

\(\blacksquare\)


Claim: if \(m\) and \(n\) are integers of the form \(4k + 1\) then so is \(mn\)#

Claim

If \(m\) and \(n\) are integers of the form \(4k + 1\) then so is \(mn\).

\( \boxed{ \forall m, n \in \mathbb{Z} \quad \exists s, t \in \mathbb{Z} \quad (m = 4s + 1) \land (n = 4t + 1) \quad \implies \quad \exists k \in \mathbb{Z} \quad mn = 4k + 1 } \)

Proof

Suppose \(m = 4s + 1\) and \(n = 4t + 1\) for some integers \(s\) and \(t\).

\(mn = (4s + 1)(4t + 1) = 16st + 4s + 4t + 1 = 4(4st + s + t) + 1\)

\(\blacksquare\)

The converse of this statement is not true in general. For example

\(3 \times 3 = 9 = 4 \times 2 + 1\) but \(3 \ne 4 k + 1\) for any integer \(k\).

Example

\( \begin{aligned} m && n & && & mn \\ 1 &= 0 \times 4 + 1 && & 1 = 0 \times 4 + 1 && & 1 = && 0 \times 4 + 1 \\ 1 &= 0 \times 4 + 1 && & 5 = 1 \times 4 + 1 && & 5 = && 1 \times 4 + 1 \\ 1 &= 0 \times 4 + 1 && & 9 = 2 \times 4 + 1 && & 9 = && 2 \times 4 + 1 \\ \vdots \\ 5 &= 1 \times 4 + 1 && & 5 = 1 \times 4 + 1 && & 25 = && 6 \times 4 + 1 \\ 5 &= 1 \times 4 + 1 && & 9 = 2 \times 4 + 1 && & 45 = && 11 \times 4 + 1 \\ 5 &= 1 \times 4 + 1 && &13 = 3 \times 4 + 1 && & 65 = && 16 \times 4 + 1 \\ 5 &= 1 \times 4 + 1 && &17 = 4 \times 4 + 1 && & 85 = && 21 \times 4 + 1 \\ \vdots \\ 9 &= 2 \times 4 + 1 && & 9 = 2 \times 4 + 1 && & 81 = && 20 \times 4 + 1 \\ \end {aligned} \)


Claim: if \(mn\) is of the form \(4k - 1\) then so is one of \(m\) or \(n\)#

Claim

If \(mn\) is of the form \(4k - 1\) then so is one of \(m\) or \(n\).

\( \boxed{ \forall m, n \in \mathbb{Z} \quad \exists k \in \mathbb{Z} \quad mn = 4k - 1 \quad \implies \quad \exists s \in \mathbb{Z} \quad m = 4s - 1 \quad \lor \quad \exists t \in \mathbb{Z} \quad n = 4t - 1 } \)

Proof

It can be shown that an integer takes one of the following forms, for some integer \(k\).

\( \begin{aligned} 4k & && = 2(2k) \\ 4k & + 1 && \\ 4k & + 2 && = 2(2k + 1) \\ 4k & + 3 && = 4(k + 1) - 1 \\ \end {aligned} \)

It is evident that an integer either takes the form \(4k \pm 1\) or is divisible by \(2\), but not both.

\(mn = 4k - 1\) is odd and so both \(m\) and \(n\) are odd. But we already know this.

We have already shown that if both \(m\) and \(n\) are of the form \(4k + 1\) then their product cannot be of the form \(4k - 1\).

In fact

\( \begin{aligned} (4s + 1)(4t + 1) &= 16st + 4s + 4t + 1 = 4(4st + s + t) + 1 \\ (4s - 1)(4t - 1) &= 16st - 4s - 4t + 1 = 4(4st - s - t) + 1 \\ (4s + 1)(4t - 1) &= 16st - 4s + 4t - 1 = 4(4st - s + t) - 1 \\ (4s - 1)(4t + 1) &= 16st + 4s - 4t - 1 = 4(4st + s - t) - 1 \\ \end {aligned} \)

\( \boxed{ \begin{aligned} \forall m, n \in \mathbb{Z} \quad & \exists k \in \mathbb{Z} \quad mn = 4k + 1 \quad \iff \quad \exists s, t \in \mathbb{Z} \quad \Big( \quad m = 4s + 1 \land n = 4t + 1 \quad \oplus \quad m = 4s - 1 \land n = 4t - 1 \quad \Big) \\ & \exists k \in \mathbb{Z} \quad mn = 4k - 1 \quad \iff \quad \exists s, t \in \mathbb{Z} \quad \Big( \quad m = 4s - 1 \land n = 4t + 1 \quad \oplus \quad m = 4s + 1 \land n = 4t - 1 \quad \Big) \\ \end {aligned} } \)

\(\blacksquare\)


Proof

\(mn = 4k - 1\) is odd and so \(m\) and \(n\) are odd so that \(m = 2s + 1\) and \(n = 2t + 1\) for some integers \(s\) and \(t\).

\( \begin{aligned} mn = 4k - 1 &= (2s + 1)(2t + 1) \\ &= 4st + 2s + 2t + 1 \\ &= 2(2st + s + t) + 1 \\ 4k &= 2(2st + s + t) + 2 \\ 2k &= (2st + s + t) + 1 \\ 2k - 1 &= 2st + s + t \end {aligned} \)

Thus \(2st + s + t\) is odd.

Suppose either both \(s\) and \(t\) are even or both \(s\) and \(t\) are odd.

\( \begin{aligned} \text{even} &= 2 \times \text{even} \times \text{even} + \text{even} + \text{even} \\ \text{even} &= 2 \times \text{odd} \times \text{odd} + \text{odd} + \text{odd} \\ \end {aligned} \)

Then \(2st + s + t\) is even. But we supposed that \(2st + s + t\) is odd. Contradiction!

Thus one of \(s\) and \(t\) must be even and the other odd, say \(s\), so that \(s = 2u + 1\) for some integer \(u\). Then

\(m = 2s + 1 = 2(2u + 1) + 1 = 4u + 2 + 1 = 4u + 3 = \boxed{4(u + 1) - 1}\)

\(n = 2t + 1 = 2(2v) + 1 = 4v + 1\)

\(\blacksquare\)

Example

\( \begin{aligned} 4 \times 1 - 1 &= 3 \\ 4 \times 2 - 1 &= 7 \\ 4 \times 3 - 1 &= 11 \\ 4 \times 4 - 1 &= 15 = \boxed{3} \times 5 \\ 4 \times 5 - 1 &= 19 \\ 4 \times 6 - 1 &= 23 \\ 4 \times 7 - 1 &= 27 \\ 4 \times 8 - 1 &= 31 \\ 4 \times 9 - 1 &= 35 = 5 \times \boxed{7} \\ 4 \times 10 - 1 &= 39 = \boxed{3} \times 13 \\ 4 \times 11 - 1 &= 43 \\ 4 \times 12 - 1 &= 47 \\ 4 \times 13 - 1 &= 51 \\ 4 \times 14 - 1 &= 55 = 5 \times \boxed{11} \\ 4 \times 15 - 1 &= 59 \\ 4 \times 16 - 1 &= 63 = \boxed{3^2 \times 7} \\ 4 \times 17 - 1 &= 67 \\ 4 \times 18 - 1 &= 71 \\ 4 \times 19 - 1 &= 75 = \boxed{3} \times 5^2 \\ 4 \times 20 - 1 &= 79 \\ 4 \times 21 - 1 &= 83 \\ 4 \times 22 - 1 &= 87 = \boxed{3} \times 29 \\ 4 \times 23 - 1 &= 91 = \boxed{7} \times 13 \\ 4 \times 24 - 1 &= 95 = 5 \times \boxed{19} \\ 4 \times 25 - 1 &= 99 = \boxed{3^2 \times 11} \\ \vdots \end {aligned} \)

Example

Numbers of the form \(4k \pm 1\) are not divisible by \(2\).

\( \begin{aligned} n \equiv \phantom{-}1 \mod 4 \quad \iff \quad n - 1 = 4k \\ n \equiv -1 \mod 4 \quad \iff \quad n + 1 = 4k \\ \end {aligned} \)

\( \begin{array}{rrrc} n & & 4.k\pm 1 & 4.k'\mp 3 \\ \hline 1 & 2. 0 + 1 & 4. 0 + 1 & 4. 1 - 3 \\ & 2. 1 - 1 & & \\ 3 & 2. 1 + 1 & 4. 1 - 1 & 4. 0 + 3 \\ & 2. 2 - 1 & & \\ 5 & 2. 2 + 1 & 4. 1 + 1 & 4. 2 - 3 \\ & 2. 3 - 1 & & \\ 7 & 2. 3 + 1 & 4. 2 - 1 & 4. 1 + 3 \\ & 2. 4 - 1 & & \\ 9 & 2. 4 + 1 & 4. 2 + 1 & 4. 3 - 3 \\ & 2. 5 - 1 & & \\ 11 & 2. 5 + 1 & 4. 3 - 1 & 4. 2 + 3 \\ & 2. 6 - 1 & & \\ 13 & 2. 6 + 1 & 4. 3 + 1 & 4. 4 - 3 \\ & 2. 7 - 1 & & \\ 15 & 2. 7 + 1 & 4. 4 - 1 & 4. 3 + 3 \\ & 2. 8 - 1 & & \\ 17 & 2. 8 + 1 & 4. 4 + 1 & 4. 5 - 3 \\ & 2. 9 - 1 & & \\ 19 & 2. 9 + 1 & 4. 5 - 1 & 4. 4 + 3 \\ & 2.10 - 1 & & \\ 21 & 2.10 + 1 & 4. 5 + 1 & 4. 6 - 3 \\ & 2.11 - 1 & & \\ 23 & 2.11 + 1 & 4. 6 - 1 & 4. 5 + 3 \\ & 2.12 - 1 & & \\ 25 & 2.12 + 1 & 4. 6 + 1 & 4. 7 - 3 \\ & 2.13 - 1 & & \\ 27 & 2.13 + 1 & 4. 7 - 1 & 4. 6 + 3 \\ & 2.14 - 1 & & \\ 29 & 2.14 + 1 & 4. 7 + 1 & 4. 8 - 3 \\ & 2.15 - 1 & & \\ 31 & 2.15 + 1 & 4. 8 - 1 & 4. 7 + 3 \\ & 2.16 - 1 & & \\ 33 & 2.16 + 1 & 4. 8 + 1 & 4. 9 - 3 \\ & 2.17 - 1 & & \\ 35 & 2.17 + 1 & 4. 9 - 1 & 4. 8 + 3 \\ & 2.18 - 1 & & \\ 37 & 2.18 + 1 & 4. 9 + 1 & 4.10 - 3 \\ & 2.19 - 1 & & \\ 39 & 2.19 + 1 & 4.10 - 1 & 4. 9 + 3 \\ & 2.20 - 1 & & \\ 41 & 2.20 + 1 & 4.10 + 1 & 4.11 - 3 \\ & 2.21 - 1 & & \\ 43 & 2.21 + 1 & 4.11 - 1 & 4.10 + 3 \\ & 2.22 - 1 & & \\ 45 & 2.22 + 1 & 4.11 + 1 & 4.12 - 3 \\ & 2.23 - 1 & & \\ 47 & 2.23 + 1 & 4.12 - 1 & 4.11 + 3 \\ & 2.24 - 1 & & \\ 49 & 2.24 + 1 & 4.12 + 1 & 4.13 - 3 \\ & 2.25 - 1 & & \\ \vdots \end {array} \)


Claim: if \(m\) and \(n\) are integers of the form \(6k + 1\) then so is \(mn\)#

Claim

If \(m\) and \(n\) are integers of the form \(6k + 1\) then so is \(mn\).

\( \boxed{ \forall m, n \in \mathbb{Z} \quad \exists s, t \in \mathbb{Z} \quad (m = 6s + 1) \land (n = 6t + 1) \quad \implies \quad \exists k \in \mathbb{Z} \quad mn = 6k + 1 } \)

Proof

Suppose \(m = 6s + 1\) and \(n = 6t + 1\) for some integers \(s\) and \(t\).

\(mn = (6s + 1)(6t + 1) = 36st + 6s + 6t + 1 = 6(6st + s + t) + 1\)

\(\blacksquare\)

The converse of this statement is not true in general. For example

\(5 \times 5 = 25 = 6 \times 4 + 1\) but \(5 \ne 6k + 1\) for any integer \(k\).


Claim: if \(mn\) is of the form \(6k - 1\) then so is one of \(m\) or \(n\)#

Claim

If \(mn\) is of the form \(6k - 1\) then so is one of \(m\) or \(n\).

\( \boxed{ \forall m, n \in \mathbb{Z} \quad \exists k \in \mathbb{Z} \quad mn = 6k - 1 \quad \implies \quad \exists s \in \mathbb{Z} \quad m = 6s - 1 \quad \lor \quad \exists t \in \mathbb{Z} \quad n = 6t - 1 } \)

Proof

It can be shown that an integer takes one of the following forms, for some integer \(k\).

\( \begin{aligned} 6k & && = 2(3k) && \text{even multiples of } 3 \\ 6k & + 1 && && \text{} \\ 6k & + 2 && = 2(3k + 1) && \text{} \\ 6k & + 3 && = 3(2k + 1) && \text{odd multiples of } 3 \\ 6k & + 4 && = 2(3k + 2) && \text{} \\ 6k & + 5 && = 6(k + 1) - 1 && \text{} \\ \end {aligned} \)

It is evident that an integer either takes the form \(6k \pm 1\) or is divisible by \(2\) or \(3\), but not both.

\(mn = 6k - 1\) is odd and so is not divisible by \(2\). Thus neither \(m\) nor \(n\) is divisible by \(2\).

Suppose either \(m\) or \(n\) is divisible by \(3\), say \(m\), so that \(3k' = m\) for some integer \(k'\). Then \(mn\) would also be divisible by \(3\), which it is not. Thus neither \(m\) nor \(n\) is divisible by \(3\).

We have already shown that if both \(m\) and \(n\) are of the form \(6k + 1\) then so are both \(m\) and \(n\).

In fact

\( \begin{aligned} (6s + 1)(6t + 1) & = 36st + 6s + 6t + 1 = 6(6st + s + t) + 1 = 6k + 1 \\ (6s - 1)(6t - 1) & = 36st - 6s - 6t + 1 = 6(6st - s - t) + 1 = 6k + 1 \\ (6s + 1)(6t - 1) & = 36st - 6s + 6t - 1 = 6(6st - s + t) - 1 = 6k - 1 \\ (6s - 1)(6t + 1) & = 36st + 6s - 6t - 1 = 6(6st + s - t) - 1 = 6k - 1 \\ \end {aligned} \)

\( \boxed{ \begin{aligned} \forall m, n \in \mathbb{Z} \quad & \exists k \in \mathbb{Z} \quad mn = 6k + 1 \quad \iff \quad \exists s, t \in \mathbb{Z} \quad \Big( \quad m = 6s + 1 \land n = 6t + 1 \quad \oplus \quad m = 6s - 1 \land n = 6t - 1 \quad \Big) \\ & \exists k \in \mathbb{Z} \quad mn = 6k - 1 \quad \iff \quad \exists s, t \in \mathbb{Z} \quad \Big( \quad m = 6s - 1 \land n = 6t + 1 \quad \oplus \quad m = 6s + 1 \land n = 6t - 1 \quad \Big) \\ \end {aligned} } \)

\(\blacksquare\)

Example

\( \begin{array}{rrrc} 6 \times \phantom{1}k - 1 \\ \hline 6 \times \phantom{1}1 - 1 & 5 \\ 6 \times \phantom{1}2 - 1 & 11 \\ 6 \times \phantom{1}3 - 1 & 17 \\ 6 \times \phantom{1}4 - 1 & 23 \\ 6 \times \phantom{1}5 - 1 & 29 \\ 6 \times \phantom{1}6 - 1 & 35 & \textcolor{#50C878}{5} \times \phantom{1}7 \\ 6 \times \phantom{1}7 - 1 & 41 \\ 6 \times \phantom{1}8 - 1 & 47 \\ 6 \times \phantom{1}9 - 1 & 53 \\ 6 \times 10 - 1 & 59 \\ 6 \times 11 - 1 & 65 & \textcolor{#50C878}{5} \times 13 \\ 6 \times 12 - 1 & 71 \\ 6 \times 13 - 1 & 77 & 7 \times \textcolor{#50C878}{11} \\ \end {array} \)


Claim: if \(m\) and \(n\) are integers of the form \(8k + 1\) then so is \(mn\)#

Claim

If \(m\) and \(n\) are integers of the form \(8k + 1\) then so is \(mn\).

\( \boxed{ \forall m, n \in \mathbb{Z} \quad \exists s, t \in \mathbb{Z} \quad (m = 8s + 1) \land (n = 8t + 1) \quad \implies \quad \exists k \in \mathbb{Z} \quad mn = 8k + 1 } \)

Proof

Suppose \(m = 8s + 1\) and \(n = 8t + 1\) for some integers \(s\) and \(t\).

\(mn = (8s + 1)(8t + 1) = 64st + 8s + 8t + 1 = 8(8st + s + t) + 1\)

\(\blacksquare\)

The converse of this statement is not true in general. For example

\(7 \times 7 = 49 = 8 \times 6 + 1\) but \(7 \ne 8k + 1\) for any integer \(k\).


False Claim: if \(mn\) is of the form \(8k - 1\) then so is one of \(m\) or \(n\)#

False Claim

If \(mn\) is of the form \(8k - 1\) then so is one of \(m\) or \(n\).

Discussion

It can be shown that an integer takes one of the following forms, for some integer \(k\).

\( \begin{aligned} & 8k && = 2(4k) \\ & 8k + 1 && \\ & 8k + 2 && = 2(4k + 1) \\ & 8k + 3 && \\ & 8k + 4 && = 2(4k + 2) \\ & 8k + 5 && = 8(k + 1) - 3 \\ & 8k + 6 && = 2(4k + 3) \\ & 8k + 7 && = 8(k + 1) - 1 \\ \end {aligned} \)

It is evident that an integer can be expressed as exactly one of the following.

  • a multiple of \(2\)

  • \(8k \pm 1\)

  • \(8k \pm 3\)

\(mn = 8k - 1\) is odd and so both \(m\) and \(n\) are odd.

\( \begin{aligned} (8s + 1)(8t + 1) & = 64st + 8s + 8t + 1 = 8(8st + s + t) + 1 = 8k + 1 \\ (8s - 1)(8t - 1) & = 64st - 8s - 8t + 1 = 8(8st - s - t) + 1 = 8k + 1 \\ (8s + 1)(8t - 1) & = 64st - 8s + 8t - 1 = 8(8st - s + t) - 1 = 8k - 1 \\ (8s - 1)(8t + 1) & = 64st + 8s - 8t - 1 = 8(8st + s - t) - 1 = 8k - 1 \\ \\ (8s + 3)(8t + 3) & = 64st + 24s + 24t + 9 = 8(8st + 3s + 3t) + 9 = 8k + 8 + 1 = 8(k + 1) + 1 \\ (8s - 3)(8t - 3) & = 64st - 24s - 24t + 9 = 8(8st - 3s - 3t) + 9 = 8k + 8 + 1 = 8(k + 1) + 1 \\ (8s + 3)(8t - 3) & = 64st - 24s + 24t - 9 = 8(8st - 3s + 3t) - 9 = 8k - 8 - 1 = 8(k - 1) - 1 \\ (8s - 3)(8t + 3) & = 64st + 24s - 24t - 9 = 8(8st + 3s - 3t) - 9 = 8k - 8 - 1 = 8(k - 1) - 1 \\ \\ (8s + 1)(8t + 3) & = 64st + 24s + 8t + 3 = 8(8st + 3s + t) + 3 = 8k + 3 \\ (8s - 1)(8t - 3) & = 64st - 24s - 8t + 3 = 8(8st - 3s - t) + 3 = 8k + 3 \\ (8s + 1)(8t - 3) & = 64st - 24s + 8t - 3 = 8(8st - 3s + t) - 3 = 8k - 3 \\ (8s - 1)(8t + 3) & = 64st + 24s - 8t - 3 = 8(8st + 3s - t) - 3 = 8k - 3 \\ \end {aligned} \)

\(\blacksquare\)

For example

\(8.5 - 1 = 39 = 3 \times 13 = (8.0 + 3) \times (8.2 - 3)\)


Claim: \(n \mid (n - 1)!\) for \(n \gt 4\)#




Primality#


Prime#

PRIME [Humphreys & Prest pp. 25]

A member of \(\mathbb{N}\) greater than \(1\) which is only divisible by \(1\) and itself is called a prime number.

In other words, let \(p\) be a positive integer with \(p \gt 1\). \(p\) is called prime if it has exactly two (positive) divisors, \(1\) and \(p\).

\( \boxed{ \forall p \in \mathbb{P} \,\, \textcolor{red}{[}\,\, Prime(p) \iff \textcolor{orange}{[}\,\, (1 \mid p) \land (p \mid p) \,\, \underbrace{ \land \,\, \forall n \in \mathbb{P} \,\, \textcolor{yellow}{[}\,\, ((1 \ne n) \land (p \ne n)) \implies (n \nmid p) \,\,\textcolor{yellow}{]} }_{uniqueness} \,\,\textcolor{orange}{]} \,\,\textcolor{red}{]} } \)

Alternatively, a prime is an integer greater than \(1\) that cannot be written as the product of two integers greater than \(1\).

\( \forall p \in \mathbb{P} \,\, [\,\, Prime(p) \iff [\,\, (p \ne 1) \land (\forall a, b \in \mathbb{P} \,\, ((p = ab) \implies ((a = 1) \lor (b = 1)))) \,\,] \,\,] \)

\(1\) is not a prime because it has exactly one (positive) divisor, and a prime number has exactly two (positive) divisors. Thus the smallest prime is \(2\) which is the only even prime, since any other hypothetical even prime \(n\) would have at least three distinct (positive) divisors, namely \(1\), \(2\), and \(n\).

The units \(\pm 1\) and the primes have no proper divisors.

\( \begin{aligned} 1 && & \textcolor{red} {1 \mid 1} \\ 2 && & \textcolor{green}{1 \mid 2} && \textcolor{green}{2 \mid 2} \\ 3 && & \textcolor{green}{1 \mid 3} && 2 \nmid 3 && \textcolor{green}{3 \mid 3} \\ 4 && & \textcolor{red} {1 \mid 4} && \textcolor{red}{2 \mid 4} && 3 \nmid 4 && \textcolor{red}{4 \mid 4} \\ 5 && & \textcolor{green}{1 \mid 5} && 2 \nmid 5 && 3 \nmid 5 && 4 \nmid 5 && \textcolor{green}{5 \mid 5} \\ 6 && & \textcolor{red} {1 \mid 6} && \textcolor{red}{2 \mid 6} && \textcolor{red}{3 \mid 6} && 4 \nmid 6 && 5 \nmid 6 && \textcolor{red}{6 \mid 6} \\ 7 && & \textcolor{green}{1 \mid 7} && 2 \nmid 7 && 3 \nmid 7 && 4 \nmid 7 && 5 \nmid 7 && 6 \nmid 7 && \textcolor{green}{7 \mid 7} \\ 8 && & \textcolor{red} {1 \mid 8} && \textcolor{red}{2 \mid 8} && 3 \nmid 8 && \textcolor{red}{4 \mid 8} && 5 \nmid 8 && 6 \nmid 8 && 7 \nmid 8 && \textcolor{red}{8 \mid 8} \\ 9 && & \textcolor{red} {1 \mid 9} && 2 \nmid 9 && \textcolor{red}{3 \mid 9} && 4 \nmid 9 && 5 \nmid 9 && 6 \nmid 9 && 7 \nmid 9 && 8 \nmid 9 && \textcolor{red}{9 \mid 9} \\ 10 && & \textcolor{red}{1 \mid 10} && \textcolor{red}{2 \mid 10} && 3 \nmid 10 && 4 \nmid 10 && \textcolor{red}{5 \mid 10} && 6 \nmid 10 && 7 \nmid 10 && 8 \nmid 10 && 9 \nmid 10 && \textcolor{red}{10 \mid 10} \\ 11 && & \textcolor{green}{1 \mid 11} && 2 \nmid 11 && 3 \nmid 11 && 4 \nmid 11 && 5 \nmid 11 && 6 \nmid 11 && 7 \nmid 11 && 8 \nmid 11 && 9 \nmid 11 && 10 \nmid 11 && \textcolor{green}{11 \mid 11} \\ \vdots \\ \end{aligned} \)

Example

To show that \(101\) is prime it must be shown that it has no divisors \(1 \lt d \lt 101\).

Suppose \(d\) with \(1 \lt d \lt 101\) is a divisor. Then there is an integer \(e\) such that \(de = 101 \quad \iff \quad e = 101/d\).

If \(d\) were \(1\) then \(e = 101/d = 101\). But \(d \gt 1\) so \(e = 101/d \lt 101\).

If \(d\) were \(101\) then \(e = 101/d = 1\). But \(d \lt 101\) so \(e = 101/d \gt 1\).

Thus \(1 \lt e \lt 101\).

If \(d = e\) then \(|d| = |e| = \sqrt{101}\)

\(d \lt \sqrt{101} \quad \iff \quad de = 101 \lt e\sqrt{101} \quad \iff \quad \sqrt{101} \lt e\)

Thus we only need to check for divisors \(d\) with \(1 \lt d \le \lfloor \sqrt{101} \rfloor\).

In fact we only need to check the primes up to \(\lfloor \sqrt{101} \rfloor\), \(2, 3, 5, 7\).

None are divisors of \(101\) and so it is prime.

for p in [2, 3, 5, 7]:
  print(101 % p)
1
2
1
3

Composite#

COMPOSITE

A positive integer greater than one that is not prime is called composite.

In particular let \(n\) be a positive integer with \(n \gt 1\). \(n\) is called composite if it can be written \(n = m_1 m_2\) with \(1 \lt m_1 \lt n\) and so \(1 \lt m_2 \lt n\) also.

\( \boxed{ } \)

Alternatively, a composite is an integer greater than \(1\) which can be written as the product of two integers greater than \(1\).

\( \forall c \in \mathbb{P} \,\, [\,\, Composite(c) \iff [\,\, (c \ne 1) \land \lnot Prime(c) \,\,] \,\,] \)

The primes and composites form a partition of the set of positive integers greater than one.


Claim: every positive integer is a product of primes#

THEOREM [Vaughan Theorem 1.4]

Every member \(n\) of \(\mathbb{N}^{+}\) (the positive integers) is a product of primes.

\( \boxed{ \forall n \in \mathbb{N}^+ \quad \exists k \ge 0 \quad n = p_1 p_2 \dots p_k = \prod_{i=1}^k p_i \quad \land \quad \text{Prime}(p_i) } \)

Proof by induction on \(n\)

It suffices to show that

\( \boxed{ \begin{aligned} & P(1) \quad \land \quad P(2) \quad \land \quad \forall \ell \ge 3 \quad \left( \bigwedge_{j=2}^{\ell-1} P(j) \right) \implies P(\ell) \\ & \text{where} \quad P(j) : \quad \exists k \ge 0 \quad j = p_1 p_2 \dots p_k = \prod_{i=1}^k p_i \quad \land \quad \text{Prime}(p_i) \\ \end {aligned} } \)

Basis

\( \begin{aligned} P(1) : & \quad n = 1 = \prod_{i=1}^{0} && \text{empty product of primes} \\ P(2) : & \quad n = \underset{p_1}{2} = \prod_{i=1}^{1} \\ \end {aligned} \)

Induction Step

We want to show that

\( \boxed{ \begin{aligned} \forall \ell \ge 3 \quad \left( \bigwedge_{j=2}^{\ell-1} P(j) \right) \implies P(\ell) \\ \end {aligned} } \)

Induction Hypothesis

Suppose all \(j \le \ell - 1\) is a product of primes. That is to say

\( \boxed{ \begin{aligned} \exists \ell \ge 3 \quad \bigwedge_{j=2}^{\ell-1} P(j) \\ \end {aligned} } \)

Then we want to show that \(P(\ell)\).

If \(\ell\) is a prime then we are done.

If \(\ell\) is not prime then it has proper divisors \(d\) and \(\frac{\ell}{d}\) with \(1 \lt d, \frac{\ell}{d} \lt \ell\).

But then on the inductive hypothesis both \(d\) and \(\frac{\ell}{d}\) are primes and so

\( \begin{aligned} P(\ell) : & \quad \ell = \underset{p_1}{d} \times \underset{p_2}{\ell/d} = \prod_{i=1}^{2} \\ \end {aligned} \)

is a product of primes.

\(\blacksquare\)


Euclid’s Theorem on the infinitude of primes#

EUCLID’S THEOREM [Vaughan Theorem 1.5] [Humphreys & Prest 1.3.4 pp. 29] Euclid’s Elements Book IX Proposition 20

There are infinitely many primes. (In other words, there is no largest prime.)

\( \boxed{ \forall p \in \mathbb{P} \,\, [\,\, Prime(p) \implies \exists q \in \mathbb{P} \,\, [\,\, Prime(q) \land (q \gt p) \,\,] \,\,] } \)

To show that there are infinitely many primes, it must be shown that every finite list of primes is missing a prime. Thus “the list of all primes” cannot be finite.

Proof by contradiction

Suppose that there are only a finite number of primes

\(p_1, p_2, \dotsc, p_n\)

the first few of which we already know, and consider the number one more than their product

\(m = p_1 p_2 \dots p_n + 1\)

Clearly \(m \gt 1\) since we already know the first few primes \(p_1 = 2, p_2 = 3, \dotsc\)

\(m\) is a product of primes since \(m \gt 1\).

In particular, there is a prime \(p\) which divides \(m\).

\(p\) must be one of \(p_1, p_2, \dotsc, p_n\) since every prime is listed here, and so \(p\) divides the product \(p_1 p_2 \dots p_n\).

Since \(p \mid m\) and \(p \mid p_1 p_2 \dots p_n\) it is the case that

\(p \mid (m - p_1 p_2 \dots p_n) = 1\)

But no prime divides \(1\), so our assumption must have been false.

\(\blacksquare\)

Since \(m\) is greater than \(1\) it has a prime factor \(p\) which can’t be any of \(p_1, p_2, \dotsc, p_n\) since \(m\) has remainder \(1\) when divided by each \(p_i\).

Euclid’s proof tells us that we can always find a prime outside of a finite list of primes \(p_1, p_2, \dotsc, p_n\) by using a prime factor of \(p_1p_2 \dots p_n + 1\), not by using \(p_1p_2 \dots p_n + 1\) itself.

\(Proof\) [Humphreys & Prest pp. 29-30]

Choose any positive integer \(n\) and let \(p_1, p_2, \dots, p_n\) be the first \(n\) prime numbers.
We will show that there is a prime number different from each of \(p_1, p_2, \dots, p_n\). Since \(n\) may be chosen as large as we like, this will show that there are not just finitely many primes.
Define the number \(N = (p_1 p_2 \dots p_n) + 1\) which need not itself be prime.
\(N\) has remainder \(1\) when divided by each of \(p_1, p_2, \dots, p_n\); in particular, none of \(p_1, p_2, \dots, p_n\) divides \(N\) exactly.
\(N\) has a prime divisor \(p\) by the fundamental theorem of arithmetic.
Since \(p \mid N\) it cannot be the case that \(p\) is equal to any of \(p_1, p_2, \dots, p_n\).
Therefore we have shown that there exists a prime which is not in our original list.

\(\blacksquare\)

The idea of this proof is to show how, given any finite set of primes, we can construct a number greater than or equal to \(2\) which is not divisible by any of them and which, therefore, must have a prime factor not in our original set.

The integer \(N\) defined in the proof need not itself be prime: we simply showed that it has a prime divisor not equal to any of \(p_1, p_2, \dots, p_n\). In principle, one may find a \(p\) as in the proof by factorizing \(N\). So the proof is, in principle, a recipe which, given any finite list of primes, will produce a new prime not already in the list.


Euler’s proof of the infinitude of primes#

Euler’s Proof of the infinitude of primes

There are an infinite number of primes.

\( \boxed{ } \)

Proof

Suppose that

\( \begin{aligned} S(x) = \sum_{n \le x} \frac{1}{n} \end {aligned} \)

Then

\( \begin{aligned} S(x) \ge \sum_{n \le x} \int_n^{n + 1} \frac{dt}{t} \ge \int_1^x \frac{dt}{t} = \log x \end {aligned} \)

Consider

\( \begin{aligned} P(x) = \prod_{p \le x} (1 - 1/p)^{-1} \end {aligned} \)

where the product is over the primes not exceeding \(x\). Then

\( \begin{aligned} P(x) &= \prod_{p \le x} (1 - 1/p)^{-1} \\ &= \prod_{p \le x} \left(1 + \frac{1}{p} + \frac{1}{p^2} + \dotsb \right) \ge \sum_{n \le x} \frac{1}{n} = S(x) \ge \log x \end {aligned} \)

Observe that when one multiplies out the LHS every fraction \(1/n\) with \(n \le x\) occurs.

Since \(\log x \to \infty\) as \(x \to \infty\) there must be infinitely many primes.

\(\blacksquare\)

THEOREM (EULER)

The sum

\( \begin{aligned} \sum_p \frac{1}{p} \end {aligned} \)

diverges.

\( \boxed{ } \)

We can be more precise. Take the \(\log\) of both sides of \(P(x) \ge \log x\)

\( \begin{aligned} \log P(x) &\ge \log \log x \\ \log \left( \prod_{p \le x} (1 - 1/p)^{-1} \right) &\ge \log \log x \\ -\sum_{p \le x} \log (1 - 1/p) &\ge \log \log x \\ \end {aligned} \)

Moreover the expression on the LHS

\( \begin{aligned} -\sum_{p \le x} \log (1 - 1/p) = \sum_{p \le x} \sum_{k = 1}^\infty \frac{1}{kp^k} \end {aligned} \)

Here the terms with \(k \ge 2\) contribute at most

\( \begin{aligned} \sum_{p \le x} \frac{1}{2} \sum_{k = 2}^\infty \frac{1}{p^k} \le \frac{1}{2} \sum_{n=2}^\infty \frac{1}{n(n - 1)} = \frac{1}{2} \end {aligned} \)

Thus we have proved that

\( \begin{aligned} \sum_{p \le x} \frac{1}{p} \ge \log \log x - \frac{1}{2} \end {aligned} \)


Claim: every number of the form \(4k - 1\) has a prime factor of this form#

Claim

Every number of the form \(4k - 1\) has a prime factor of this form.

\( \boxed{ } \)

Proof

A number of the form \(4k - 1\) is odd and is not divisible by \(2\), the only even prime.

Thus its prime factors are odd each of the form \(4k \pm 1\).

If all prime factors were of the form \(4k + 1\) then so would be their product.

Thus at least one must be of the form \(4k - 1\).

\(\blacksquare\)


Claim: there are infinitely many primes of the form \(4k - 1\)#

Claim

There are infinitely many primes of the form \(4k - 1\).

\( \boxed{ } \)

Proof by contradiction

Suppose there are only a finite number of primes \(p_1, \dotsc, p_n\) of the form \(4k - 1\) and consider the number one less than four times their product

\(m = 4p_1 p_2 \dots p_n - 1\)

Clearly \(m \gt 1\) since we already know the first few primes of this form. Thus \(m\) has at least one prime factor \(p\) of the form \(4k - 1\) and in particular there is a prime \(p\) which divides \(m\).

\(p\) must be one of \(p_1, \dotsc, p_n\), and so \(p\) also divides \(p_1 p_2 \dots p_n\). Thus

\(p \mid (4p_1 p_2 \dots p_n - m) = 1\). But no prime divides \(1\), so our assumption must have been false.

\(\blacksquare\)


Claim: every number of the form \(6k - 1\) has a prime factor of this form#

Claim

Every number of the form \(6k - 1\) has a prime factor of this form.

\( \boxed{ } \)

Proof

A number of the form \(6k - 1\) is odd and so is not divisible by \(2\), the only even prime, nor by \(3\).

Thus its prime factors are odd each of the form \(6k \pm 1\).

If all prime factors were of the form \(6k + 1\) then so would be their product.

Thus at least one must be of the form \(6k - 1\).

\(\blacksquare\)

Example


Claim: there are infinitely many primes of the form \(6k - 1\)#

Claim

There are infinitely many primes of the form \(6k - 1\).

In other words, there are an infinite number of primes that do not have the factors \(2\) and \(3\) (i.e., every prime other than \(2\) and \(3\)).

\( \boxed{ } \)

Proof by contradiction

Suppose there are only a finite number of primes \(p_1, \dotsc, p_n\) of the form \(6k - 1\) and consider the number one less than six times their product

\(m = 6p_1 p_2 \dots p_n - 1\)

Clearly \(m \gt 1\) since we already know the first few primes of this form. Thus \(m\) has at least one prime factor \(p\) of the form \(6k - 1\) and in particular there is a prime \(p\) which divides \(m\).

\(p\) must be one of \(p_1, \dotsc, p_n\), and so \(p\) also divides \(p_1 p_2 \dots p_n\). Thus

\(p \mid (6p_1 p_2 \dots p_n - m) = 1\). But no prime divides \(1\), so our assumption must have been false.

\(\blacksquare\)


Claim: \(p \mid a \iff p \mid a^n\)#

Claim

\(p \mid x \iff p \mid x^k\) for any \(k \gt 0\)

\( \boxed{ } \)

Proof

First Direction \(p \nmid x \implies p \nmid x^k\)

\(p \mid x \iff pk = x \iff (pk)^n = x^n \iff p(p^{n-1}k^n) = x^n \iff p \mid x^n\)

\(p \nmid x \iff x \not\equiv 0 \mod p \implies x^k \not\equiv 0 \mod p \iff p \nmid x^k\)

Second Direction \(p \nmid x^k \implies p \nmid x\)

Suppose \(p \mid x \iff x \equiv 0 \mod p\) and then \(x^k \equiv 0^k \equiv 0 \mod p \iff p \mid x^k\).

\(\blacksquare\)


\( \begin{array}{rrcc} 1 & 2. 0 + 1 & 4. 0 + 1 & 6.0 + 1 & 8.0 + 1 & \\ & 2. 1 - 1 & & & & \\ 3 & 2. 1 + 1 & 4. 1 - 1 & & & \\ & 2. 2 - 1 & & & & \\ 5 & 2. 2 + 1 & 4. 1 + 1 & 6.1 - 1 & & \\ & 2. 3 - 1 & & & & \\ 7 & 2. 3 + 1 & 4. 2 - 1 & 6.1 + 1 & 8.1 - 1 & \\ & 2. 4 - 1 & & & & \\ 9 & 2. 4 + 1 & 4. 2 + 1 & & 8.1 + 1 & \\ & 2. 5 - 1 & & & & \\ 11 & 2. 5 + 1 & 4. 3 - 1 & 6.2 - 1 & & \\ & 2. 6 - 1 & & & & \\ 13 & 2. 6 + 1 & 4. 3 + 1 & 6.2 + 1 & & \\ & 2. 7 - 1 & & & & \\ 15 & 2. 7 + 1 & 4. 4 - 1 & & 8.2 - 1 & \\ & 2. 8 - 1 & & & & \\ 17 & 2. 8 + 1 & 4. 4 + 1 & 6.3 - 1 & 8.2 + 1 & \\ & 2. 9 - 1 & & & & \\ 19 & 2. 9 + 1 & 4. 5 - 1 & 6.3 + 1 & & \\ & 2.10 - 1 & & & & \\ 21 & 2.10 + 1 & 4. 5 + 1 & & & \\ & 2.11 - 1 & & & & \\ 23 & 2.11 + 1 & 4. 6 - 1 & 6.4 - 1 & 8.3 - 1 & \\ & 2.12 - 1 & & & & \\ 25 & 2.12 + 1 & 4. 6 + 1 & 6.4 + 1 & 8.3 + 1 & \\ & 2.13 - 1 & & & & \\ 27 & 2.13 + 1 & 4. 7 - 1 & & & \\ & 2.14 - 1 & & & & \\ 29 & 2.14 + 1 & 4. 7 + 1 & 6.5 - 1 & & \\ & 2.15 - 1 & & & & \\ 31 & 2.15 + 1 & 4. 8 - 1 & 6.5 + 1 & 8.4 - 1 & \\ & 2.16 - 1 & & & & \\ 33 & 2.16 + 1 & 4. 8 + 1 & & 8.4 + 1 & \\ & 2.17 - 1 & & & & \\ 35 & 2.17 + 1 & 4. 9 - 1 & 6.6 - 1 & & \\ & 2.18 - 1 & & & & \\ 37 & 2.18 + 1 & 4. 9 + 1 & 6.6 + 1 & & \\ & 2.19 - 1 & & & & \\ 39 & 2.19 + 1 & 4.10 - 1 & & 8.5 - 1 & \\ & 2.20 - 1 & & & & \\ 41 & 2.20 + 1 & 4.10 + 1 & 6.7 - 1 & 8.5 + 1 & \\ & 2.21 - 1 & & & & \\ 43 & 2.21 + 1 & 4.11 - 1 & 6.7 + 1 & & \\ & 2.22 - 1 & & & & \\ 45 & 2.22 + 1 & 4.11 + 1 & & & \\ & 2.23 - 1 & & & & \\ 47 & 2.23 + 1 & 4.12 - 1 & 6.8 - 1 & 8.6 - 1 & \\ & 2.24 - 1 & & & & \\ 49 & 2.24 + 1 & 4.12 + 1 & 6.8 + 1 & 8.6 + 1 & \\ & 2.25 - 1 & & & & \\ \end {array} \)


\( \begin{array}{l} 2k & \\ 2k + 1 &= 2(k + 1) - 1 \\ \end {array} \)

\( \begin{aligned} & 2 \mid n && \iff 2k = n - 0 \iff n \equiv \phantom{\pm}0 \mod 2 \\ & 2 \mid n \pm 1 && \iff 2k = n \pm 1 \iff n \equiv \mp 1 \mod 2 \\ \end {aligned} \)

An integer takes exactly one of the following forms.

  • multiple of \(2\)

  • \(2k \pm 1\) - an odd number is expressed as both \(2k + 1\) for some \(k\) and as \(2k' - 1\) with \(k' = k + 1\)


\( \begin{array}{llll} 4k &= 2(2k) & & \text{multiples of both } 2 \text{ and } 4 \\ 4k + 1 & &= 4(k + 1) - 3 & \text{} \\ 4k + 2 &= 2(2k + 1) &= 4(k + 1) - 2 & \text{multiples of } 2 \text{ but not } 4 \\ 4k + 3 & &= 4(k + 1) - 1 & \text{} \\ \end {array} \)

An integer takes exactly one of the following forms.

  • multiple of \(2\)

    • multiple of \(2, 4\)

    • multiple of \(2\) but not \(4\)

  • odd number of the form \(4k \pm 1\)

    • both \(4k + 1\) for some \(k\) and \(4k' - 3\) with \(k' = k + 1\)

    • both \(4k - 1\) for some \(k\) and \(4k' + 3\) with \(k' = k - 1\)

\( \begin{aligned} & 4 \mid n && \iff 4k = n - 0 \iff n \equiv \phantom{-1 \equiv \pm} 0 \mod 4 \\ & 4 \mid n + 1 && \iff 4k = n + 1 \iff n \equiv -1 \equiv \phantom{\pm} 3 \mod 4 && \iff 4 \mid n - 3 \\ & 4 \mid n \pm 2 && \iff 4k = n \pm 2 \iff n \equiv \phantom{-1 \equiv} \mp 2 \mod 4 \\ & 4 \mid n + 3 && \iff 4k = n + 3 \iff n \equiv -3 \equiv \phantom{\pm} 1 \mod 4 && \iff 4 \mid n - 1 \\ \end {aligned} \)

\( \begin{aligned} (4k)^2 &&&= 4(4k^2) &&= 4k' \\ (4k + 1)^2 &= 16k^2 + 8k + 1 &&= 4(2k(2k + 1) + 1 &&= 4k' + 1 \\ (4k + 2)^2 &= 16k^2 + 16k + 4 &&= 4(4k( k + 1) + 1) &&= 4k' \\ (4k + 3)^2 &= 16k^2 + 24k + 9 &&= 4(4k^2 + 6k + 2) + 1 &&= 4k' + 1 \\ \end {aligned} \)

\( \begin{aligned} n \equiv 0 \mod 4 \quad \iff \quad n^2 \equiv 0 \mod 4 \\ n \equiv 1 \mod 4 \quad \iff \quad n^2 \equiv 1 \mod 4 \\ n \equiv 2 \mod 4 \quad \iff \quad n^2 \equiv 0 \mod 4 \\ n \equiv 3 \mod 4 \quad \iff \quad n^2 \equiv 1 \mod 4 \\ \end {aligned} \)


\( \begin{array}{llll} 6k &= 2(3k) & & \text{multiples of } 2, 3, 6 \\ 6k + 1 & &= 6(k + 1) - 5 & \text{} \\ 6k + 2 &= 2(3k + 1) &= 6(k + 1) - 4 & \text{multiples of } 2 \text{ but not } 3, 6 \\ 6k + 3 &= 3(2k + 1) &= 6(k + 1) - 3 & \text{multiples of } 3 \text{ but not } 2, 6 \\ 6k + 4 &= 2(3k + 2) &= 6(k + 1) - 2 & \text{multiples of } 2 \text{ but not } 3, 6 \\ 6k + 5 & &= 6(k + 1) - 1 & \text{} \\ \end {array} \)

An integer takes exactly one of the following forms.

  • multiple of \(2\)

    • multiple of \(2, 3, 6\)

    • multiple of \(2\) but not \(3, 6\)

  • odd multiple of \(3\)

  • odd number of the form \(6k \pm 1\)

    • both \(6k + 1\) for some \(k\) and \(6k' - 5\) with \(k' = k + 1\)

    • both \(6k - 1\) for some \(k\) and \(6k' + 5\) with \(k' = k - 1\)

\( \begin{aligned} & 6 \mid n && \iff 6k = n - 0 \iff n \equiv \phantom{-1 \equiv \pm} 0 \mod 6 \\ & 6 \mid n + 1 && \iff 6k = n + 1 \iff n \equiv -1 \equiv \phantom{\pm} 5 \mod 6 & \iff 6 \mid n - 5 \\ & 6 \mid n + 2 && \iff 6k = n + 2 \iff n \equiv -2 \equiv \phantom{\pm} 4 \mod 6 & \iff 6 \mid n - 4 \\ & 6 \mid n \pm 3 && \iff 6k = n \pm 3 \iff n \equiv \phantom{-1 \equiv} \mp 3 \mod 6 \\ & 6 \mid n + 4 && \iff 6k = n + 4 \iff n \equiv -4 \equiv \phantom{\pm} 2 \mod 6 & \iff 6 \mid n - 2 \\ & 6 \mid n + 5 && \iff 6k = n + 5 \iff n \equiv -5 \equiv \phantom{\pm} 1 \mod 6 & \iff 6 \mid n - 1 \\ \end {aligned} \)


\( \begin{array}{llll} 8k &= 2(2(2k)) & & \text{multiples of } 2, 4, 8 \\ 8k + 1 & &= 8(k + 1) - 7 & \text{} \\ 8k + 2 &= 2(4k + 1) &= 8(k + 1) - 6 & \text{multiples of } 2 \text{ but not } 4, 8 \\ 8k + 3 & &= 8(k + 1) - 5 & \text{} \\ 8k + 4 &= 2(2(2k + 1)) &= 8(k + 1) - 4 & \text{multiples of } 2, 4 \text{ but not } 8 \\ 8k + 5 & &= 8(k + 1) - 3 & \text{} \\ 8k + 6 &= 2(4k + 3) &= 8(k + 1) - 2 & \text{multiples of } 2 \text{ but not } 4, 8 \\ 8k + 7 & &= 8(k + 1) - 1 & \text{} \\ \end {array} \)

An integer takes exactly one of the following forms.

  • multiple of \(2\)

    • multiple of \(2, 4, 8\)

    • multiple of \(2, 4\) but not \(8\)

    • multiple of \(2\), but not \(4, 8\)

  • odd number of the form \(8k \pm 1\)

    • both \(8k + 1\) for some \(k\) and \(8k' - 7\) with \(k' = k + 1\)

    • both \(8k - 1\) for some \(k\) and \(8k' + 7\) with \(k' = k - 1\)

  • odd number of the form \(8k \pm 3\)

    • both \(8k + 3\) for some \(k\) and \(8k' - 5\) with \(k' = k + 1\)

    • both \(8k - 3\) for some \(k\) and \(8k' + 5\) with \(k' = k - 1\)

\( \begin{aligned} & 8 \mid n && \iff 8k = n - 0 \iff n \equiv \phantom{-1 \equiv \pm} 0 \mod 8 \\ & 8 \mid n + 1 && \iff 8k = n + 1 \iff n \equiv -1 \equiv \phantom{\pm} 7 \mod 8 & \iff 8 \mid n - 7 \\ & 8 \mid n + 2 && \iff 8k = n + 2 \iff n \equiv -2 \equiv \phantom{\pm} 6 \mod 8 & \iff 8 \mid n - 6 \\ & 8 \mid n + 3 && \iff 8k = n + 3 \iff n \equiv -3 \equiv \phantom{\pm} 5 \mod 8 & \iff 8 \mid n - 5 \\ & 8 \mid n \pm 4 && \iff 8k = n \pm 4 \iff n \equiv \phantom{-1 \equiv} \mp 4 \mod 8 \\ & 8 \mid n + 5 && \iff 8k = n + 5 \iff n \equiv -5 \equiv \phantom{\pm} 3 \mod 8 & \iff 8 \mid n - 3 \\ & 8 \mid n + 6 && \iff 8k = n + 5 \iff n \equiv -6 \equiv \phantom{\pm} 2 \mod 8 & \iff 8 \mid n - 2 \\ & 8 \mid n + 7 && \iff 8k = n + 5 \iff n \equiv -7 \equiv \phantom{\pm} 1 \mod 8 & \iff 8 \mid n - 1 \\ \end {aligned} \)


\( \begin{array}{llll} 10k &= 2(5k) & & \text{multiples of } 2, 5, 10 \\ 10k + 1 & &= 10(k + 1) - 9 & \text{} \\ 10k + 2 &= 2(5k + 1) &= 10(k + 1) - 8 & \text{multiples of } 2 \text{ but not } 5, 10 \\ 10k + 3 & &= 10(k + 1) - 7 & \text{} \\ 10k + 4 &= 2(5k + 2) &= 10(k + 1) - 6 & \text{multiples of } 2 \text{ but not } 5, 10 \\ 10k + 5 &= 5(2k + 1) &= 10(k + 1) - 5 & \text{multiples of } 5 \text{ but not } 2, 10 \\ 10k + 6 &= 2(5k + 3) &= 10(k + 1) - 4 & \text{multiples of } 2 \text{ but not } 5, 10 \\ 10k + 7 & &= 10(k + 1) - 3 & \text{} \\ 10k + 8 &= 2(5k + 4) &= 10(k + 1) - 2 & \text{multiples of } 2 \text{ but not } 5, 10 \\ 10k + 9 & &= 10(k + 1) - 1 & \text{} \\ \end {array} \)

An integer takes exactly one of the following forms.

  • multiple of \(2\)

    • multiple of \(2, 5, 10\)

    • multiple of \(2\) but not \(5, 10\)

  • odd multiple of \(5\)

  • odd number of the form \(10k \pm 1\)

    • both \(10k + 1\) for some \(k\) and \(10k' - 9\) with \(k' = k + 1\)

    • both \(10k - 1\) for some \(k\) and \(10k' + 9\) with \(k' = k - 1\)

  • odd number of the form \(10k \pm 3\)

    • both \(10k + 3\) for some \(k\) and \(10k' - 7\) with \(k' = k + 1\)

    • both \(10k - 3\) for some \(k\) and \(10k' + 7\) with \(k' = k - 1\)


\( \begin{array}{llll} 12k &= 2(2(3k)) & & \text{multiples of } 2, 3, 4, 6, 12 \\ 12k + 1 & &= 12(k + 1) - 11 & \text{} \\ 12k + 2 &= 2(6k + 1) &= 12(k + 1) - 10 & \text{multiples of } 2 \text{ but not } 3, 4, 6, 12 \\ 12k + 3 &= 3(4k + 1) &= 12(k + 1) - 9 & \text{multiples of } 3 \text{ but not } 2, 4, 6, 12 \\ 12k + 4 &= 2(2(3k + 1)) &= 12(k + 1) - 8 & \text{multiples of } 2, 4 \text{ but not } 3, 6, 12 \\ 12k + 5 & &= 12(k + 1) - 7 & \text{} \\ 12k + 6 &= 2(3(2k + 1)) &= 12(k + 1) - 6 & \text{multiples of } 2, 3, 6 \text{ but not } 4, 12 \\ 12k + 7 & &= 12(k + 1) - 5 & \text{} \\ 12k + 8 &= 2(2(3k + 2)) &= 12(k + 1) - 4 & \text{multiples of } 2, 4 \text{ but not } 3, 6, 12 \\ 12k + 9 &= 3(4k + 3) &= 12(k + 1) - 3 & \text{multiples of } 3 \text{ but not } 2, 4, 6, 12 \\ 12k + 10 &= 2(6k + 5) &= 12(k + 1) - 2 & \text{multiples of } 2 \text{ but not } 3, 4, 6, 12 \\ 12k + 11 & &= 12(k + 1) - 1 & \text{} \\ \end {array} \)

An integer takes exactly one of the following forms.

  • multiple of \(2\)

    • multiple of \(2, 3, 4, 6, 12\)

    • multiple of \(2, 3, 6\) but not \(4, 12\)

    • multiple of \(2, 4\) but not \(3, 6, 12\)

    • multiple of \(2\) but not \(3, 4, 6, 12\)

  • odd multiple of \(3\)

  • odd number of the form \(12k \pm 1\)

    • both \(12k + 1\) for some \(k\) and \(12k' - 11\) with \(k' = k + 1\)

    • both \(12k - 1\) for some \(k\) and \(12k' + 11\) with \(k' = k - 1\)

  • odd number of the form \(12k \pm 5\)

    • both \(12k + 5\) for some \(k\) and \(12k' - 7\) with \(k' = k + 1\)

    • both \(12k - 5\) for some \(k\) and \(12k' + 7\) with \(k' = k - 1\)




Division Theorem#

Division of an integer by a positive integer produces a quotient and a remainder. (Operating on remainders will form the basis of modular arithmetic.)

THEOREM: DIVISION ALGORITHM

Let \(a\) be an integer and \(d\) a positive integer. Then there are unique integers \(q\) and \(r\) with \(0 \le r \lt d\) s.t.

\(a = dq + r\)

where \(d\) is called the divisor; \(a\) is called the dividend; \(q\) is called the quotient; and \(r\) is called the remainder.

\( \boxed{ \begin{aligned} \forall a, d \in \mathbb{Z} \quad \Big( \quad d \ne 0 \quad \implies \quad \exists ! q, r \in \mathbb{Z} \quad \Big( a = dq + r \quad \land \quad 0 \le r \lt |d| \Big) \Big) \end {aligned} } \)

Sometimes we say that \(d\) is a non-zero integer so that \(0 \le r \lt |d|\).

If \(d \mid a\) then \(r = 0\).

If \(d \nmid a\) then \(r \ne 0\) and satisfies the stronger inequalities \(0 \lt r \lt |d|\).

In other words, remainders are nonnegative.

The integer \(a\) is divisible by the integer \(d\) iff the remainder is \(0\) when \(a\) is divided by \(d\):

\(d \mid a \iff a = dq + 0\)


Proof

Existence

Let \(D = \{ a - dx \mid x \in \mathbb{Z} \} = \{ a, a \pm d, a \pm 2d, a \pm 3d, \dotsc \}\).

No matter what \(a\) is, \(D\) has at least one non-negative element and so has a least non-negative element \(r\).

If \(a \ge 0\) then since \(a \in D\) it is the case that \(r \in D\).

If \(a \lt 0\) then \(a - d(a - 1) \gt 0\). Since \(a - d(a - 1) \in D\) it is the case that \(r \in D\).

\( \begin{aligned} a &&& \phantom{-}a - d(\phantom{-}a - 1) \\ \hline -1 &&& -1 - d(-1 - 1) = -1 + 2d \\ -2 &&& -2 - d(-2 - 1) = -2 + 3d \\ -3 &&& -3 - d(-3 - 1) = -3 + 4d \\ \vdots \end {aligned} \)

Thus no matter what \(a\) is we know that \(r \in D\) which is by definition non-negative.

Thus \(a - dx = r\) for some \(x\), call it \(q\).

Then \(a = dq + r\) with \(0 \le r\).

Suppose \(r \ge d\). Then

\(a = dq + r = dq + (d + r - d) = d(q + 1) + (r - d)\) with \(0 \le r - d \lt r\). Contradiction!

\(r\) is the least non-negative element of \(D\), not \(r - d\). Therefore, it must be the case that \(r \lt d\).

Uniqueness

Suppose there is a second solution \(a = dq' + r'\) with \(0 \le r' \lt d\).

Then \(0 = a - a = (dq' + r') - (dq + r) = d(q' - q) + (r' - r) \iff d|q' - q| = |r' - r|\).

\(d \le d|q' - q|\) and \(|r' - r| \lt d\)

Contradiction!

\(\blacksquare\)


Proof by contradiction

Assume \(a\) and \(b\) are positive.

If \(b \gt a\), then just take \(q = 0, r = a\).

\[ a = 0 \times b + a \]

Therefore, let \(b \le a\).

Consider the set of non-negative differences between \(b\) and integer multiples of \(a\).

\[ D = \{ a - bk : a - bk \ge 0 \land k \in \mathbb{N} \} \]

\(D\) is non-empty since it contains \(a = a - b \cdot 0\) and \(a \ge b \gt 0\).

By the well-ordering principle, \(D\) contains a least element: \(r = a - bq\), say.

\(Contradictory \,\, step\)

If it were the case that \(r\) was not strictly less than \(b\), then we would have \(r - b \ge 0\)

\[ r \not\lt b \implies r - b \ge 0 \]

and, therefore, \(r - b = (a - bq) - b = a - b(q + 1)\).

\[\begin{split} \begin{align*} r &= a - bq \\ r - b &= a - b(q + 1) \\ \implies r - b &\lt r && Contradiction! \\ \end{align*} \end{split}\]

Then \(r - b\) would be a member of \(D\) strictly less than \(r\), contradicting the minimality of \(r\).

Therefore, \(r\) does satisfy \(0 \le r \lt b\).

\(\blacksquare\)

[Bressoud pp. 7]

[Humphreys & Prest 1.1.1 pp. 3-4]

Example

Let \(a = 3\) and \(b = 7\).

Then there are integers \(q\) and \(r\) st \(7 = 3q + r\) with \(0 \le r \lt |3|\).

\(7 = 2 \cdot 3 + 1\) with \(0 \le 1 \lt |3|\).

Let \(a = 4\) and \(b = 12\).

Then there are integers \(q\) and \(r\) st \(12 = 4q + r\) with \(0 \le r \lt |4|\).

\(12 = 3 \cdot 4 + 0\) with \(0 \le 0 \lt |4|\).

Let \(a = 4\) and \(b = -9\).

Then there are integers \(q\) and \(r\) st \(-9 = 4q + r\) with \(0 \le r \lt |4|\).

\(-9 = (-3) \cdot 4 + 3\) with \(0 \le 3 \lt |4|\).

Note that \(q = -2\) and \(r = -1\) do not satisfy \(0 \le r \lt |4|\).

\(-9 = (-2) \cdot 4 + (-1)\) but not with \(0 \le -1 \lt |4|\).

[Humphreys & Prest pp. 4, 14]

Note on notation and programming#

We can use the following notation to express the quotient and the remainder:

\( \begin{aligned} q &= a \textbf{ div } d \\ r &= a \textbf{ mod } d \\ \end {aligned} \)

When \(a\) is an integer and \(d\) is a positive integer:

\( \begin{aligned} q &= a \textbf{ div } d &&= \lfloor a/d \rfloor \\ r &= a \textbf{ mod } d &&= a - d \lfloor a/d \rfloor \\ \end {aligned} \)

If \(d\) is fixed then \(\textbf{div}\) and \(\textbf{mod}\) are functions on the set of integers:

\( \begin{aligned} \textbf{div}_d &: \mathbb{Z} \to \mathbb{Z} & \textbf{div}_d(a) \mapsto q \\ \textbf{mod}_d &: \mathbb{Z} \to \mathbb{N} & \textbf{mod}_d(a) \mapsto r \\ \end {aligned} \)

In programming languages, the modulo operator for \(a \lt 0\) may return \(a - d \lceil a/d \rceil\) instead of \(a \textbf{ mod } d = a - d \lfloor a/d \rfloor\). Also unlike \(a \textbf{ mod } d\) the modulo operator may be defined when \(d \lt 0\), and even when \(d = 0\).

\( \begin{aligned} 17 & \textbf{ mod } 3 = & 17 - 3 & \times \lfloor \underset{ 5.\bar{6}}{\phantom{-}17/3} \rfloor = 2 && & 17 &= 3 \times 5 + 2 \\ -17 & \textbf{ mod } 3 = & -17 - 3 & \times \lfloor \underset{-5.\bar{6}}{ -17/3} \rfloor = 1 && & -17 &= 3 \times (-6) + 1 \\ \end {aligned} \)

print(f'{ 17 %  3:>2}')
print(f'{-17 %  3:>2}')
print(f'{-17 % -3:>2}')
print(f'{ 17 % -3:>2}')
 2
 1
-2
-1

Division via repeated subtraction#

# division via repeated subtraction
# positive integers 1 <= d <= n
def udiv (n, d):
  q, r = 0, n
  while r >= d:
    r -= d
    q += 1
  return q, r

def div (n, d):
  assert(d != 0)
  if d < 0:
    q, r = udiv(n, -d)
    return -q, r
  if n < 0:
    q, r = div(-n, d)
    if r == 0:
      return -q, 0
    else:
      return -q-1, d-r
  return udiv(n, d)

n = -20
d = 3
q, r = div(n, d)
print(f'{n} = {d} x {q} + {r}')
-20 = 3 x -7 + 1



GCD#

GCD

Given two integers \(a, b\) not both \(0\), define

\(D(a, b) = \{ ax + by \mid x, y \in \mathbb{Z} \}\)

Then \(D(a, b)\) has positive elements.

Let \(\gcd(a, b)\) denote the least positive element. Then \(\gcd(a, b)\) has the following properties.

(i) \(\gcd(a, b) \mid a\)

(ii) \(\gcd(a, b) \mid b\)

(iii) if the integer \(c\) satisfies \(c \mid a\) and \(c \mid b\) then \(c \mid \gcd(a, b)\)

Note that \(\gcd(a, b)\) divides every member of \(D(a, b)\).

\( \boxed{ } \)

Proof

Existence

The following demonstrates that no matter which values we choose for \(a\) and \(b\) there are always values of \(x\) and \(y\) which make their linear combination positive. The case \(a = b = 0\) is excluded by the theorem.

\( \begin{aligned} a & \gt 0 && \implies a \times \phantom{(-}1\phantom{)} && + b \times \phantom{(-}0\phantom{)} = \phantom{-}a && \gt 0 \\ b & \gt 0 && \implies a \times \phantom{(-}0\phantom{)} && + b \times \phantom{(-}1\phantom{)} = \phantom{-}b && \gt 0 \\ a & \lt 0 && \implies a \times (-1) && + b \times \phantom{(-}0\phantom{)} = -a && \gt 0 \\ b & \lt 0 && \implies a \times \phantom{(-}0\phantom{)} && + b \times (-1) = -b && \gt 0 \\ \end {aligned} \)

Thus, the set \(D(a, b)\) has at least one positive element, and so there is a least positive element.

Uniqueness

(i) and (ii)

Suppose \(\gcd(a, b) \nmid a\). From the division algorithm we have \(a = \gcd(a, b)q + r\) with \(0 \le r \lt \gcd(a, b)\) and \(\gcd(a, b) \nmid a\) implies \(0 \lt r\).

\(r = a - \gcd(a, b)q = a - (ax + by)q = a(1 - xq) + b(-yq)\) for some integers \(x, y\).

\(0 \lt \underbrace{a(1 - xq) + b(-yq)}_{r} \lt \underbrace{ax + by}_{\gcd(a, b)}\)

Contradiction! \(r\) can’t be less than \(\gcd(a, b)\) since \(\gcd(a, b)\) is the least element. Thus, \(\gcd(a, b) \mid a\) and by symmetry \(\gcd(a, b) \mid b\).

(iii)

Suppose there is an integer \(c\) such that \(c \mid a\) and \(c \mid b\). Then \(a = cu\) and \(b = cv\) for some integers \(u, v\).

\(\gcd(a, b) = ax + by = (cu)x + (cv)y = c(ux + vy) \iff c \mid \gcd(a, b)\)

\(\blacksquare\)

\(Theorem\) [Humphreys & Prest 1.1.2 pp. 6]

Let \(a\) and \(b\) be positive integers. \(a, b \in \mathbb{P}\)
There is a positive integer \(d\) such that

(i) \(d\) divides \(a\) and \(d\) divides \(b\), and
(ii) if \(c\) is a positive integer which divides both \(a\) and \(b\) then \(c\) divides \(d\) (i.e., any common divisor of \(a\) and \(b\) divides \(d\)).

\[ \forall a, b \in \mathbb{P} \,\, [ \,\, \exists d \in \mathbb{P} \,\, ((d \mid a \land d \mid b) \land (\forall c \in \mathbb{P} ((c \mid a \land c \mid b) \implies c \mid d))) \,\, ] \]

\(Proof \,\, by \,\, contradiction\) [Humphreys & Prest pp. 6]

Let \(D\) be the set of all positive integers of the form \(as + bt\) where \(s\) and \(t\) vary over the set of all integers.

\[ D = \{ as + bt : s, t \in \mathbb{Z}, as + bt \gt 0 \} \]

\(D\) is non-empty since \(a = a \cdot 1 + b \cdot 0\) is in \(D\).
\(D\) has a least element \(d\) by the well-ordering principle.
Since \(d\) is in \(D\), there are integers \(s\) and \(t\) such that \(d = as + bt\).
We must show that (ii) any common divisor \(c\) of \(a\) and \(b\) is a divisor of \(d\).

Let \(c \mid a\) and \(c \mid b\).
Then there are integers \(g\) and \(h\) such that \(a = cg\) and \(b = ch\).
\(as + bt = (cg)s + (ch)t = c(gs + ht) \implies c \mid c(gs + ht) \implies c \mid as + bt \implies c \mid d\)
\(\therefore c \mid d\)

We must show that (i) \(d \mid a\) and \(d \mid b\).
Showing that \(d \mid a\) is sufficient because \(a\) and \(b\) are interchangeable throughout the proof and so, by symmetry, \(d \mid b\).

We may write \(a = dq + r \,\, , \,\, 0 \le r \lt d\) by the division theorem.
To show that \(d \mid a\) is to show that \(r = 0\).
\(a = dq + r \implies \textcolor{green}{r} = a - dq = a - (as + bt)q = \textcolor{green}{a(1 - sq) + b(-tq)}\)
If \(r\) were positive then it would meet the criteria of \(D\) and so would belong to \(D\).
But \(d\) was chosen to be minimal in \(D\) and \(r\) is strictly less than \(d\). \(Contradiction!\)
\(\therefore (r = 0) \land (d \mid a) \land (d \mid b)\)

\(\blacksquare\)

\(Definition\) [Humphreys & Prest pp. 7] [Bressoud pp. 6]

Let \(a\) and \(b\) be integers.
The integer \(d\) satisfying conditions (i) and (ii) of theorem 1.1.2 is called the greatest common divisor of \(a\) and \(b\) and is denoted \(gcd(a, b)\).
In other words, the greatest common divisor of \(a\) and \(b\) is the largest positive integer which divides both \(a\) and \(b\).

Note that \(gcd(a, b) = gcd(b, a)\).
Note that if \(a \mid b\) then \(a = gcd(a, b)\).


Claim: \(\gcd(a/d, b/d) = 1\) with \(d = \gcd(a, b)\)#

Claim

\( \begin{aligned} \gcd \left( \frac{a}{\gcd(a, b)}, \frac{b}{\gcd(a, b)} \right) = 1 \end {aligned} \)

\( \boxed{ } \)

Proof

Let this quantity be denoted \(g\). Then

\( \begin{aligned} & g \Bigm\vert \frac{a}{\gcd(a, b)} \iff gk = \frac{a}{\gcd(a, b)} \iff g \gcd(a, b) k = a \iff g \gcd(a, b) \mid a \\ & g \Bigm\vert \frac{b}{\gcd(a, b)} \iff gk = \frac{b}{\gcd(a, b)} \iff g \gcd(a, b) k = b \iff g \gcd(a, b) \mid b \\ \end {aligned} \)

Whatever integer divides both of two integers divides their \(\gcd\) and so

\(g \gcd(a, b) \mid \gcd(a, b) \iff \iff g \gcd(a, b) k = \gcd(a, b) \iff gk = 1 \iff g \mid 1 \iff g = 1\)

Note that it is not true that \(g = \pm 1\) since the definition of the \(\gcd\) is restricted to positive integers.

\(\blacksquare\)


Claim: \(\gcd(a + by, b) = \gcd(a, b)\)#

Claim

Suppose \(a\) and \(b\) are not both \(0\).

Then for any integer \(y\) we have

\(\gcd(a + by, b) = \gcd(a, b)\).

\( \boxed{ } \)

Proof

Since \(\gcd(a, b) \mid a\) and \(\gcd(a, b) \mid b\) we know that \(\gcd(a, b) \mid ax + by\) for any integers \(x, y\). Thus \(\gcd(a, b) \mid a + by\).

Since \(\gcd(a, b) \mid a + by\) and \(\gcd(a, b) \mid b\) we know that \(\gcd(a, b) \mid \gcd(a + by, b)\).

Since \(\gcd(a + by, b) \mid a + by\) and \(\gcd(a + by, b) \mid b\) we know that \(\gcd(a + by, b) \mid (a + by)s + bt\) for any integers \(s, t\). Thus \(\gcd(a + by, b) \mid a + by - by = a\).

Since \(\gcd(a + by, b) \mid a\) and \(\gcd(a + by, b) \mid b\) we know that \(\gcd(a + by, b) \mid \gcd(a, b)\).

Since \(\gcd(a, b) \mid \gcd(a + by, b)\) and \(\gcd(a + by, b) \mid \gcd(a, b)\) it is the case that \(\gcd(a, b) = \gcd(a + by, b)\).

\(\blacksquare\)

Example

\(\gcd(21, 49) = \gcd(21 + 49(3), 49)\)


Claim: \(\gcd(a, b) = 1 \implies \gcd(a^m, b^n) = 1\)#

UNDER CONSTRUCTION


Claim: if \(\gcd(a, b) = 1\) and \(ax = by\) then \(x = bz, y = az\)#

Claim

Suppose that \(\gcd(a, b) = 1\) and that \(ax = by\). Then there is a \(z\) such that \(x = bz\) and \(y = az\).

\( \boxed{ } \)

Proof

There are integers \(u, v\) such that

\(\gcd(a, b) = 1 = ua + vb \iff x = uax + vbx \iff x = u(by) + vbx = b\underbrace{(uy + vx)}_{z} \iff b \mid x\)

\(\gcd(a, b) = 1 = ua + vb \iff y = uay + vby \iff y = uay + v(ax) = a\underbrace{(uy + vx)}_{z} \iff a \mid y\)

\(\blacksquare\)

Example

\( \begin{aligned} \gcd(a, b) &= 1 &&& a \times x &= b \times y &&& x &= b \times z &&& y &= a \times z \\ \gcd(2, 3) &= 1 &&& 2 \times 3 &= 3 \times 2 &&& 3 &= 3 \times 1 &&& 2 &= 2 \times 1 \\ \gcd(3, 5) &= 1 &&& 3 \times 10 &= 5 \times 6 &&& 10 &= 5 \times 2 &&& 6 &= 3 \times 2 \\ \end {aligned} \)


Bézout’s Identity#

Claim

Suppose that \(a\) and \(b\) are integers not both \(0\).

Then there are integers \(x, y\) such that \(\gcd(a, b) = ax + by\).

\( \boxed{ } \)

Proof

\(\blacksquare\)

Later we will look at a way of finding suitable x and y in examples. As it stands the theorem gives no constructive way of finding them. It is a pure existence proof.

[Bressoud Lemma 1.5 pp. 6]

[Vaughan Corollary 1.14]

Example

\( \begin{array}{r|r|r|c} a & b & \gcd(a, b) & ax + by \\ \hline 21 & 6 & 3 & 21 \cdot 1 + 6 \cdot (-3) = 21 \cdot (-1) + 6 \cdot 4 \\ \end {array} \)

[Bressoud pp. 6]


Claim: \(\gcd(a, b)\) is the smallest positive integral linear combination of \(a\) and \(b\)#

Claim

Let \(a\) and \(b\) be positive integers.

The greatest common divisor \(d\) of \(a\) and \(b\) is the smallest positive integral linear combination of \(a\) and \(b\). That is, \(d = as + bt\) for some integers \(s\) and \(t\).

\( \boxed{ } \)

Proof

\(\blacksquare\)


Claim: \(\gcd(am, bm) = m \gcd(a, b)\)#

Claim

\(\gcd(am, bm) = m \gcd(a, b)\)

\( \boxed{ } \)

Proof

Let \(d = \gcd(a, b)\).

It suffices to show that both

\(md \mid \gcd(am, bm)\)

and

\(\gcd(am, bm) \mid md\)

We know that

\( \begin{aligned} & d \mid a && \iff & \exists a_1 \quad da_1 &= a && \iff & a_1 &= a/d \\ & d \mid b && \iff & \exists b_1 \quad db_1 &= b && \iff & b_1 &= b/d \\ \end {aligned} \)

with \(\gcd(a/d, b/d) = \gcd(a_1, b_1) = 1 = a_1 s + b_1 t\) for some integers \(s\) and \(t\).

\( \begin{aligned} & d \mid a && \iff & dm & \mid am && \iff & (dm) a_1 &= am \\ & d \mid b && \iff & dm & \mid bm && \iff & (dm) b_1 &= bm \\ \end {aligned} \)

Thus \(dm \mid \gcd(am, bm) = amx + bmy\) for some integers \(x\) and \(y\).

On the other hand

\( \begin{aligned} \forall x, y \in \mathbb{Z} \quad \gcd(am, bm) \mid (amx + bmy) = a_1 dmx + b_1 dmy = dm(a_1 x + b_1 y) \\ \end {aligned} \)

In particular

\( \begin{aligned} \gcd(am, bm) \mid dm \underbrace{(a_1 s + b_1 t)}_{1} \end {aligned} \)

\(\blacksquare\)

An alternative proof has been given.

\( \begin{aligned} \gcd(am, bm) = \underset{as + bt \ge 1}{\min_{s, t}}(ams + bmt) = m \underset{as + bt \ge 1}{\min_{s, t}}(as + bt) = m \gcd(a, b) \end {aligned} \)

This follows from a property of the minimum.

Let \(c \ge 1\). Then

\( \begin{aligned} \min(cx) = c \min(x) \end {aligned} \)

\(\blacksquare\)


Euclid’s Lemma#

The following theorem is a property which is characteristic of primes and is sometimes used to define them.

EUCLID’S LEMMA

Suppose that \(p\) is prime and that there are integers \(a\) and \(b\) such that \(p \mid ab\).

Then either \(p \mid a\) or \(p \mid b\) but not both.

\( \boxed{ \forall p \in \mathbb{P} \,\, [\,\, Prime(p) \implies \forall a, b \in \mathbb{Z} \,\, [\,\, (p \mid ab) \implies ((p \mid a) \lor (p \mid b)) \,\,] \,\,] } \)

Note that the following cases hold as a consequence.

If a prime \(p\) divides \(a^2\), then it must divide \(a\).

\[ \forall p \in \mathbb{P} \,\, [\,\, Prime(p) \implies \forall a \in \mathbb{Z} \,\, [\,\, (p \mid a^2) \implies (p \mid a) \,\,] \,\,] \]

Therefore, if \(p\) divides \(a^2\), then \(p^2\) divides \(a^2\).

\[ \forall p \in \mathbb{P} \,\, [\,\, Prime(p) \implies \forall a \in \mathbb{Z} \,\, [\,\, (p \mid a^2) \implies (p^2 \mid a^2) \,\,] \,\,] \]

Contrapositive: If \(p \nmid a\) and \(p \nmid b\) then \(p \nmid ab\).

\( \begin{aligned} p \mid ab \implies [(p \mid a \lor p \mid b) \land \lnot(p \mid a \land p \mid b)] \\ [ \lnot[(p \mid a \lor p \mid b) \land \lnot(p \mid a \land p \mid b)] ] \implies p \nmid ab \\ [ \lnot(p \mid a \lor p \mid b) \lor (p \mid a \land p \mid b) ] \implies p \nmid ab \\ [ p \nmid a \land p \nmid b \lor (p \mid a \land p \mid b) ] \implies p \nmid ab \\ \end {aligned} \)

Proof

If \(a = 0\) or \(b = 0\) then the result that \(p \mid 0\) is trivial. Thus we may suppose that \(ab \ne 0\).

If \(p \mid a\) then we are done.

Suppose \(p \nmid a\).

We know that there are integers \(x\) and \(y\) such that \(\gcd(a, p) = ax + py\) and that \(\gcd(a, p) \mid a\) and \(\gcd(a, p) \mid p\).

Since \(p\) is prime it is the case that either \(\gcd(a, p) = 1\) or \(\gcd(a, p) = p\).

If it were the case that \(\gcd(a, p) = p\) then \(p \mid a\). But we supposed that \(p \nmid a\).

So \(\gcd(a, p) = 1 = ax + py \iff b = abx + pby\).

\(p \mid ab \iff ab = pc\) for some integer \(c\). Then \(b = (pc)x + pby \iff b = p(cx + by) \iff p \mid b\)

\(\blacksquare\)

[Bressoud pp. 6]

[Humphreys & Prest Theorem 1.3.1 pp. 26]

[Vaughan Theorem 1.15]

Example

\( \begin{array}{c|c|c|c} p & ab \\ \hline 3 & \phantom{1}6 = 3 \times 2 \\ \hline 3 & 15 = 3 \times 5 \\ \hline \end {array} \)

Euclid’s Lemma is not obvious

Consider the set of integers \(\mathcal{A}\) of the form \(4k + 1\) which is closed under multiplication:

\((4k_1 + 1)(4k_2 + 1) = 4^2k_1k_2 + 4k_1 + 4k_2 + 1 = 4 (\underbrace{4k_1k_2 + k_1 + k_2}_{k_3}) + 1\)

Here are the first few members of this set:

\( \begin{aligned} 4(1) + 1 &= \phantom{1} 5 \\ 4(2) + 1 &= \phantom{1} 9 \\ 4(3) + 1 &= 13 \\ 4(4) + 1 &= 17 \\ 4(5) + 1 &= 21 \\ \color{red}{4(6) + 1} &\phantom{.} \color{red}{= 25} \\ 4(7) + 1 &= 29 \\ 4(8) + 1 &= 33 \\ 4(9) + 1 &= 37 \\ 4(10) + 1 &= 41 \\ \color{red}{4(11) + 1} &\phantom{.} \color{red}{= 45} \\ 4(12) + 1 &= 49 \\ \end {aligned} \)

A prime in this system is defined as a number which is only divisible by \(1\) and itself:

\(5, 9, 13, 17, 21, 29, 33, 37, 41, 49, \dotsc\)

The prime factorization of \(25\) in this system is \(5 \times 5\) and the prime factorization of \(45\) in this system is \(5 \times 9\).

In this system, prime factorization is not unique: \(441 = 9 \times 49 = 21^2\)

\(21 \mid 9 \times 49\) but \(21 \nmid 9\) and \(21 \nmid 49\)

\(\mathcal{A}\) is not closed under addition, but \(\mathbb{Z}\) is.


Extension of Euclid’s lemma#

The following lemma is an extension of the previous theorem.

Claim

Let \(p\) be prime and let \(p\) divide the product \(a_1 a_2 \dots a_r\).

Then \(p\) divides at least one of \(a_1, a_2, \dots, a_r\).

\( \boxed{ } \)

Proof by induction on \(r\)

Base Case

If \(p \mid a_1\) then \(p \mid a_1\).

Induction Step

Induction Hypothesis: Let \(p \mid b_1 b_2 \dots b_{r - 1}\) so that \(p\) divides at least one of \(b_1, b_2, \dots, b_{r - 1}\).
Let \(p\) divide the product \(a_1 \dots a_r\) which we want to write as a product \(b_1 \dots b_{r - 1}\) of \(r - 1\) integers.
Define \(b_i = a_i\) for \(i \le r - 2\) and let \(b_{r - 1}\) be the product \(a_{r - 1} a_r\).
Then \(a_1 a_2 \dots a_{r - 2} (a_{r - 1} a_r)\) is a product of \(r - 1\) integers.
Either \(p\) divides one of \(a_1, a_2, \dots, a_{r - 2}\) or \(p\) divides \(a_{r - 1} a_r\).
If the latter, then either \(p\) divides \(a_{r - 1}\) or \(p\) divides \(a_r\).

Therefore \(p\) divides one of \(a_1, a_2, \dots, a_r\).

\(\blacksquare\)

[Humphreys & Prest Lemma pp. 27]


Claim: if \(p \mid p_1 \dots p_j \dots p_r\) then \(p = p_j\) for some \(1 \le j \le r\)#

Euclid’s Lemma can be used to establish the following.

Claim

Suppose that

\(p, p_1, p_2, \dotsc, p_r\)

are primes and that

\(p \mid p_1 p_2 \dots p_r\)

Then \(p = p_j\) for some \(j\) with \(1 \le j \le r\).

\( \boxed{ } \)

Proof by induction on \(r\)

Base Case \(r = 1\)

\(p \mid p_1 \implies p = p_1\)

Induction Step

Suppose the \(r\)-th case is established and that \(p \mid p_1 p_2 \dots p_r p_{r + 1}\).

Then either \(p \mid p_{r + 1}\) or \(p \mid p_1 p_2 \dots p_r\).

If \(p \mid p_{r + 1}\) then \(p = p_{r + 1}\). Otherwise it has been established that if \(p \mid p_1 p_2 \dots p_r\) then \(p = p_j\) for some \(j\) with \(1 \le j \le r\).

\(\blacksquare\)

[Vaughan Theorem 1.17]


Computing GCD#

Claim

Let \(a\) and \(b\) be non-negative integers with \(a \ne 0\).

Let \(b = aq + r\) where \(q\) and \(r\) are positive integers.

Then \(gcd(a, b) = gcd(a, r)\).

\( \boxed{ \color{red} \forall a, b \in \mathbb{N} \,\, [ \,\, ((a \ne 0) \land (\exists q, r \in \mathbb{P} \,\, (b = aq + r))) \implies gcd(a, b) = gcd(a, r) \,\, ] } \)

Proof

Suppose \(d = \gcd(a, b)\).

\(\blacksquare\)

[Humphreys & Prest Lemma 1.1.4 pp. 8] Euclid’s Elements Book VII Proposition 1

\(Proof\) [Humphreys & Prest pp. 8]

Let \(d = gcd(a, b)\).
\(b = aq + r \iff b - aq = r\)

By definition, \(d \mid a\) and \(d \mid b\).
Then \(d \mid b - aq \iff d \mid r\) and so \(d\) is a common divisor of \(a\) and \(r\).
\(\therefore d \mid gcd(a, r)\) since a common divisor of two integers also divides their \(gcd\).

By definition, \(gcd(a, r) \mid a\) and \(gcd(a, r) \mid r\).
\(gcd(a, r) \mid aq + r \iff gcd(a, r) \mid b\) and so \(gcd(a, r)\) is a common divisor of \(a\) and \(b\).
\(\therefore gcd(a, r) \mid d\) since a common divisor of two integers also divides their \(gcd\).

\(\therefore d = gcd(a, r) = gcd(a, b)\) since \(d \mid gcd(a, r)\) and \(gcd(a, r) \mid d\).

\(\blacksquare\)

\(Example\) [Humphreys & Prest pp. 8-9]

Let \(a = 30\) and \(b = 171\).
Then we can write \(171 = 30q + r\) with \(q = 5\) and \(r = 21\) (or \(q = 3\) and \(r = 81\)).
Let \(d = gcd(30, 171)\).
\(171 = 30 \cdot 5 + 21 \iff 171 - 30 \cdot 5 = 21\)

By definition, \(d \mid 30\) and \(d \mid 171\).
Then \(d \mid 171 - 30 \cdot 5 \iff d \mid 21\).
\(\therefore d \mid gcd(30, 21)\).

By definition, \(gcd(30, 21) \mid 30\) and \(gcd(30, 21) \mid 21\).
\(gcd(30, 21) \mid 30 \cdot 5 + 21 \iff gcd(30, 21) \mid 171\).
\(gcd(30, 21) \mid d\).

\(\therefore d = gcd(30, 21) = gcd(30, 171)\).


Prime Factorization#

Prime Factorization

The decomposition of a positive integer into primes is called its prime factorization, which is expressed by

\( n = p_1^{a_1} \times p_2^{a_2} \times \dots \times p_r^{a_r} \)

where \(p_1, p_2, \dots, p_r\) are distinct primes.


Coprimality#

\(Definition\) [Bressoud pp. 3]

If integers \(m\) and \(n\) have no common primes in their respective factorizations then \(m\) and \(n\) are said to be relatively prime.

\(Example\) [Bressoud pp. 3]

\(45 = 3 \times 3 \times 5\) and \(98 = 2 \times 7 \times 7\) are relatively prime.

\(Definition\) [Humphreys & Prest pp. 12]

Let \(a\) and \(b\) be positive integers.
If \(gcd(a, b) = 1\) then \(a\) and \(b\) are said to be relatively prime.

Does this hold for all integers?

Claim:#

\(Theorem\) [Humphreys & Prest 1.1.6 pp. 13]

Let \(a\), \(b\), and \(c\) be positive integers with \(a\) and \(b\) relatively prime.
Then

  1. if \(a\) divides \(bc\) then \(a\) divides \(c\)

\[ \color{red} \forall a, b, c \in \mathbb{P} \,\, [ \,\, (RelativePrimes(a, b) \land (a \mid bc)) \implies (a \mid c) \,\, ] \]
  1. if \(a\) divides \(c\) and \(b\) divides \(c\) then \(ab\) divides \(c\)

\[ \color{red} \forall a, b, c \in \mathbb{P} \,\, [ \,\, (RelativePrimes(a, b) \land (a \mid c) \land (b \mid c)) \implies (ab \mid c) \,\, ] \]
A generalization of Euclid's lemma?

\(Proof\) [Humphreys & Prest 1.1.6 pp. 13]

Since \(a\) and \(b\) are relatively prime there are integers \(s\) and \(t\) st \(1 = as + bt\) by Bézout’s identity.
\(1 = as + bt \iff c = cas + cbt = a(cs) + bc(t)\).

Let \(a \mid bc\).
Since \(a \mid a\) and \(a \mid bc\) it is the case that \(a \mid a(cs) + bc(t) = c\).
\(\therefore a \mid c\).

Let \(a \mid c\)
Then there is an integer \(m\) such that \(am = c\).
Let \(b \mid c\)
Then there is an integer \(n\) such that \(bn = c\).
\(c = cas + cbt = (bn)as + (am)bt = ab(ns) + ab(mt) = ab(ns + mt) \implies ab \mid c\).
\(\therefore ab \mid c\).

Alternatively

Let \(a \mid c\).
\(a \mid c \implies ab \mid cb \implies ab \mid cbt\).
Let \(b \mid c\).
\(b \mid c \implies ab \mid ac \implies ab \mid cas\).
\(\therefore ab \mid cas + cbt = c\).

\(\blacksquare\)


Claim: \(a\) and \(b\) are coprime iff \(a^2\) and \(b^2\) are coprime#

\(Claim\)

\(m\) and \(n\) are relatively prime iff \(m^2\) and \(n^2\) are relatively prime.
Let

\( \begin{aligned} m &= p_1^{a_1} \times p_2^{a_2} \times \dots \times p_r^{a_r} \\ n &= p_1^{b_1} \times p_2^{b_2} \times \dots \times p_r^{b_r} \\ \end{aligned} \)

\(gcd(m, n) = 1\) implies that \(b_i = 0\) whenever \(a_i \gt 0\) and vice versa.

\( \begin{aligned} m^2 &= p_1^{2a_1} \times p_2^{2a_2} \times \dots \times p_r^{2a_r} \\ n^2 &= p_1^{2b_1} \times p_2^{2b_2} \times \dots \times p_r^{2b_r} \\ \end{aligned} \)


Pythagorean Triples#

[DEFINITION - (fundamental) Pythagorean triples]

Three integers \((x, y, z)\) which satisfy \(x^2 + y^2 = z^2\) are called a Pythagorean triple. If they are all positive and have no common factors, then they are called a fundamental triple.

\( \color{red}\boxed{ \begin{aligned} & \forall x, y, z \in \mathbb{P} \,\, (PythagoreanTriple(x, y, z) \iff (x^2 + y^2 = z^2)) \\ & \forall x, y, z \in \mathbb{P} \,\, (FundamentalTriple(x, y, z) \iff (PythagoreanTriple(x, y, z) \land RelativePrimes(x, y, z) \land (x, y, z \gt 0))) \\ & RelativePrimes(x, y, z) \iff (RelativePrimes(x, y) \land RelativePrimes(y, z) \land RelativePrimes(x, z)) \\ & (x, y, z \gt 0) \iff ((x \gt 0) \land (y \gt 0) \land (z \gt 0)) \\ \end{aligned} } \)

Because of the symmetry in \(x\) and \(y\), \((x, y, z)\) and \((y, x, z)\) are considered to be the same triple.

\( \begin{aligned} & (3, 4, 5) && \text{fundamental} \\ & (5, 12, 13) && \text{fundamental} \\ & (6, 8, 10) = 2 \times (3, 4, 5) && \text{Pythagorean} \\ \end{aligned} \)


[PROBLEM]

If we want to find all Pythagorean triples, it is sufficient to first find all fundamental triples and then take multiples of the fundamental triples.

Euclid’s Formula#

[THEOREM 1.3 - Euclid’s Formula]

Given any pair of relatively prime integers \((a, b)\) such that one of them is odd and the other even and \(a \gt b \gt 0\), then

\((a^2 - b^2, 2ab, a^2 + b^2)\)

is a fundamental triple.

\( \color{red}\boxed{ \forall a, b \in \mathbb{P} \,\, ((RelativePrimes(a, b) \land EvenOdd(a, b) \land (a \gt b \gt 0)) \implies FundamentalTriple(a^2 + b^2, 2ab, a^2 - b^2)) } \)

\( \boxed{ \begin{aligned} & EvenOdd(a, b) \iff ((Even(a) \land Odd(b)) \oplus (Odd(a) \land Even(b))) \\ & (a \gt b \gt 0) \iff ((a \gt b) \land (b \gt 0)) \\ \end{aligned} } \)

Furthermore, every fundamental triple is of this form.

\( \color{red}\boxed{ \forall x, y, z \in \mathbb{P} \,\, (FundamentalTriple(x, y, z) \implies \exists a, b \in \mathbb{P} \,\, (RelativePrimes(a, b) \land EvenOdd(a, b) \land (a \gt b \gt 0) \land (x = a^2 + b^2) \land (y = 2ab) \land (z = a^2 - b^2))) } \)

Note that the first and third terms are odd and the second term is even.

\[\begin{split} \begin{align*} (Even(a) \land Odd(b) ) & \implies (Even(a^2) \land Odd(b^2) \land Even(2ab) \land Odd(a^2 - b^2) \land Odd(a^2 + b^2)) \\ (Odd(a) \land Even(b)) & \implies (Odd(a^2) \land Even(b^2) \land Even(2ab) \land Odd(a^2 - b^2) \land Odd(a^2 + b^2)) \\ \end{align*} \end{split}\]

First few fundamental triples

\( \begin{aligned} & a = 2, b = 1 && (3, 4, 5) && (2^2 - 1^2, 2(2)(1), 2^2 + 1^2) = (4 - 1, 2 \times 2, 4 + 1) \\ & a = 3, b = 2 && (5, 12, 13) && (3^2 - 2^2, 2(3)(2), 3^2 + 2^2) = (9 - 4, 2 \times 6, 9 + 4) \\ & a = 4, b = 1 && (15, 8, 17) && (4^2 - 1^2, 2(4)(1), 4^2 + 1^2) = (16 - 1, 2 \times 4, 16 + 1) \\ & a = 4, b = 3 && (7, 24, 25) && (4^2 - 3^2, 2(4)(3), 4^2 + 3^2) = (16 - 9, 2 \times 12, 16 + 9) \\ & a = 5, b = 2 && (21, 20, 29) && (5^2 - 2^2, 2(5)(2), 5^2 + 2^2) = (25 - 4, 2 \times 10, 25 + 4) \\ & a = 5, b = 4 && (9, 40, 41) && (5^2 - 4^2, 2(5)(4), 5^2 + 4^2) = (25 - 16, 2 \times 20, 25 + 16) \\ & a = 6, b = 1 && (35, 12, 37) && (6^2 - 1^2, 2(6)(1), 6^2 + 1^2) = (36 - 1, 2 \times 6, 36 + 1) \\ & a = 6, b = 5 && (11, 60, 61) && (6^2 - 5^2, 2(6)(5), 6^2 + 5^2) = (36 - 25, 2 \times 30, 36 + 25) \\ & a = 7, b = 2 && (45, 28, 53) && (7^2 - 2^2, 2(7)(2), 7^2 + 2^2) = (49 - 4, 2 \times 14, 49 + 4) \\ & a = 7, b = 4 && (33, 56, 65) && (7^2 - 4^2, 2(7)(4), 7^2 + 4^2) = (49 - 16, 2 \times 28, 49 + 16) \\ & a = 7, b = 6 && (13, 84, 85) && (7^2 - 6^2, 2(7)(6), 7^2 + 6^2) = (49 - 36, 2 \times 42, 49 + 36) \\ & a = 8, b = 1 && (63, 16, 65) && (8^2 - 1^2, 2(8)(1), 8^2 + 1^2) = (64 - 1, 2 \times 8, 64 + 1) \\ & a = 8, b = 3 && (55, 48, 73) && (8^2 - 3^2, 2(8)(3), 8^2 + 3^2) = (64 - 9, 2 \times 24, 64 + 9) \\ & a = 8, b = 5 && (39, 80, 89) && (8^2 - 5^2, 2(8)(5), 8^2 + 5^2) = (64 - 25, 2 \times 40, 64 + 25) \\ & a = 8, b = 7 && (15, 112, 113) && (8^2 - 7^2, 2(8)(7), 8^2 + 7^2) = (64 - 49, 2 \times 56, 64 + 49) \\ & a = 9, b = 2 && (77, 36, 85) && (9^2 - 2^2, 2(9)(2), 9^2 + 2^2) = (81 - 4, 2 \times 18, 81 + 4) \\ & a = 9, b = 4 && (65, 72, 97) && (9^2 - 4^2, 2(9)(4), 9^2 + 4^2) = (81 - 16, 2 \times 36, 81 + 16) \\ \end{aligned} \)

\(Proof\)

1

That \((a^2 - b^2, 2ab, a^2 + b^2)\) is a fundamental triple for any pair of relatively prime integers \((a, b)\) such that one of them is odd and the other even and \(a \gt b \gt 0\).

Let \(a \gt b\) be two positive integers.

Then \(a^2 - b^2\), \(2ab\), and \(a^2 + b^2\) are positive integers and

\( \begin{aligned} (a^2 - b^2)^2 + (2ab)^2 &= (a^2 + b^2)^2 \\ a^4 - 2a^2b^2 + b^4 + 4a^2b^2 &= a^4 + 2a^2b^2 + b^4 \\ \end{aligned} \)

\(Proof \,\, by \,\, contradiction\)

2

That a triple is fundamental iff it has the form \((a^2 - b^2, 2ab, a^2 + b^2)\) for a pair of relatively prime integers \((a, b)\) such that one of them is odd and the other even and \(a \gt b \gt 0\).

Let \((x, y, z)\) be a fundamental triple. Then it follows from the definition of a fundamental triple that since \(x\), \(y\), and \(z\) are not all even, at most one of them is even.

Assume \(x\) and \(y\) are both odd. Then \(x^2\) and \(y^2\) are each one more than a multiple of \(4\) and so \(z^2\) must be two more than a multiple of \(4\).

\( \begin{aligned} x &= 2k + 1 \\ x^2 &= (2k + 1)^2 \\ &= 4(k^2 + k) + 1 \\ &= 4\ell + 1 && \text{for integer} \, \ell = k^2 + k \\ \end{aligned} \)

\( \begin{aligned} z^2 &= x^2 + y^2 \\ &= (4\ell + 1) + (4\mathcal{m} + 1) \\ &= 4\mathcal{n} + 2 && \text{for integer} \, \mathcal{n} = \ell + \mathcal{m} \\ &= 2(2\mathcal{n} + 1) \\ 2 &\mid z^2 \\ 2 \mid z^2 &\rightarrow 4 \mid z^2 && \text{Euclid's lemma} \\ 4 &\mid z^2 && \text{modus ponens} \\ z^2 &\ne 4n && \text{contradiction} \\ \end{aligned} \)

Therefore, either \(x\) or \(y\) is even. By symmetry in \(x\) and \(y\) we can assume it is \(y = 2m\) that is even.

\( \begin{aligned} y^2 &= z^2 - x^2 \\ &= (z - x) \times (z + x) \\ m^2 &= \frac{z - x}{2} \times \frac{z + x}{2} \end{aligned} \)

Since \(x\) and \(z\) are each odd, both \(\frac{x - z}{2}\) and \(\frac{x + z}{2}\) are integers and they are relatively prime because any common divisor would have to divide both their sum and their difference, but \(x\) and \(z\) have no common divisors from the definition of a fundamental triple.

\( \begin{aligned} \frac{z - x}{2} + \frac{z + x}{2} &= z \\ \frac{z - x}{2} - \frac{z + x}{2} &= x \\ \end{aligned} \)

\( \begin{aligned} p \mid \frac{z - x}{2} &\rightarrow p \mid m^2 \\ p \mid m^2 &\rightarrow p^2 \mid m^2 && \text{Euclid's lemma} \\ \end{aligned} \)

Since \(p \nmid \frac{z + x}{2}\) it must be the case that \(p^2 \mid \frac{z - x}{2}\).

Thus the factorization will only have even exponents which is another way of saying that \(\frac{z - x}{2}\) is a perfect square. Similarly, \(\frac{z + x}{2}\) is a perfect square.

\( \begin{aligned} \frac{z + x}{2} &= a^2 \\ \frac{z - x}{2} &= b^2 \\ \end{aligned} \)

\(a\) and \(b\) are relatively prime.

Since \(a^2 + b^2 = z\) is odd, one of \(a\) or \(b\) is odd and the other is even.

\( \begin{aligned} x &= a^2 - b^2 \\ y &= \sqrt{z^2 - x^2} \\ &= \sqrt{(a^4 + 2a^2b^2 + b^4) - (a^4 - 2a^2b^2 + b^4)} \\ &= 2ab \\ z &= a^2 + b^2 \\ \end{aligned} \)

\(\blacksquare\)




Fundamental Theorem of Arithmetic#

FUNDAMENTAL THEOREM OF ARITHMETIC [Vaughan Theorem 1.18]

Factorization into primes is unique up to ordering of the factors (i.e., regardless of the ordering of the multiplicands).

More precisely, if \(a\) is a nonzero integer and \(a \ne \pm 1\) then \(a = (\pm 1) p_1 p_2 \dots p_r\) for some \(r \ge 1\) and primes \(p_1, p_2, \dotsc, p_r\).

The choice of \(r\), the sign, and the factors \(p_j\) are unique.

We can write \(a = (\pm 1) p_1 p_2 \dots p_r\) even when \(a = \pm 1\) by interpreting the product over primes as an empty product.

Proof by induction on \(r\)

It is clear that we may suppose that \(a \gt 0\); thus that \(a \ge 2\).

Existence

We already know from [Vaughan Theorem 1.4] that \(a\) is a product of primes: \(a = p_1 p_2 \dots p_r\) with \(r \ge 1\).

Uniqueness

Base Case \(r = 1\)

Suppose \(r = 1\) so that \(a = p_1 = p_1' p_2' \dots p_s'\) where \(s \ge 1\).

Then \(p_1' \mid p_1 \implies p_1' = p_1 \iff p_1 = p_1 p_2' \dots p_s' \iff 1 = p_2' \dots p_s' \implies s = 1\)

Inductive Case

Suppose that \(r \ge 1\) and that uniqueness has been established for all products of \(r\) primes.

Suppose that \(a = p_1 p_2 \dots p_{r + 1} = p_1' p_2' \dots p_s'\) for some \(r \ge 1\)

Then by [Vaughan Theorem 1.17] \(p_1' = p_j\) for some \(j\) and then

\(p_2' \dots p_s' = p_1 p_2 \dots p_{r + 1} / p_j\)

and the inductive hypothesis can be applied to obtain the desired conclusion.

\(\blacksquare\)

Fundamental Theorem (alternative)

Every integer greater than \(1\) has a prime factor.

Inductive Hypothesis: Let \(1 \lt m \lt n\) have a prime factor.

  • Case: \(n\) is prime.

  • Case: \(n\) is not prime. Then it has a factorization \(n = ab\) where \(1 \lt a, b \lt n\). By the inductive hypothesis, \(a\) has a prime factor \(p\). Since \(p \mid a\) and \(a \mid n\) it is the case that \(p \mid n\).

\(Theorem\) [Bressoud 1.4 pp. 5]

Factorization into primes is unique up to order.

\(Example\) [Bressoud]

There may be several ways of ordering the primes that go into a factorization, but we cannot change the primes that go into the factorization.

\( \begin{aligned} 30 &= 2 \times 3 \times 5 \\ &= 3 \times 5 \times 2 \\ &= 5 \times 2 \times 3 \\ \end{aligned} \)

This does not hold for the extended integers (of the form \(m + n \sqrt{10}\)).

\( \begin{aligned} 6 &= 2 \times 3 \\ &= (4 + \sqrt{10}) \times (4 - \sqrt{10}) \\ \end{aligned} \)

\(Proof\) [Bressoud]

Sketch of the proof. It will be proved that every integer with non-unique factorization has a proper divisor with non-unique factorization. If there were integers with non-unique factorization, then there would eventually be a prime with non-unique factorization. This contradicts the definition of a prime, that a prime has no divisors other than itself and unity.

Let \(n\) be an integer with non-unique (but distinct) factorization \(n = p_1 \times p_2 \times \dots \times p_r = q_1 \times q_2 \times \dots \times q_r\) where the primes are not necessarily distinct, but where the second factorization is not simply a reordering of the first.
The prime \(q_1\) divides \(n\) and so it divides the product of the \(p_i\) s.

\( \begin{aligned} q_1 &\mid n \\ q_1 &\mid (p_1 \times p_2 \times \dots \times p_r) \\ q_1 &\mid p_i && p_i \in \{ p_1, p_2, \dots, p_r \} \, \text{by repeated application of Euclid's lemma} \\ q_1 &\mid p_1 && \text{by reordering of the} \, p_i \, \text{s} \\ q_1 &= p_1 && \text{since} \, Prime(p_1) \\ \end{aligned} \)

\( \begin{aligned} \frac{n}{q_1} &= p_2 \times p_3 \times \dots \times p_r \\ &= q_2 \times q_3 \times \dots \times q_s \\ \end{aligned} \)

Since the factorizations of \(n\) are distinct, the factorizations of \(\frac{n}{q_1}\) are distinct.

Therefore \(\frac{n}{q_1}\) is a proper divisor of \(n\) with non-unique factorization.

\(\blacksquare\)

The following theorem says that, in some sense, the primes are the multiplicative building blocks from which every (positive) integer may be produced in a unique way. Therefore positive integers, other than \(1\), which are not prime are referred to as composite.

\(Theorem\) [Humphreys & Prest pp. 28] Euclid’s Elements Book VII Proposition 31.

Every positive integer \(n\) greater than or equal to \(2\) may be written in the form \(n = p_1 p_2 \dots p_r\) where the integers \(n = p_1, p_2, \dots, p_r\) are prime numbers (which need not be distinct) and \(r \ge 1\). This factorization is unique in the sense that if also \(n = q_1 q_2 \dots q_s\) where \(q_1, q_2, \dots, q_s\) are primes, then \(r = s\) and we can renumber the \(q_i\) so that \(q_i = p_i\) for \(i = 1, 2, \dots, r\). In other words, up to rearrangement, there is just one way of writing a positive integer as a product of primes.

The idea of the following proof is as follows. If \(n\) is not prime then factor it as \(ab\). If \(a\) is not prime then factor it and if \(b\) is not prime then factor it. Continue splitting any factors which are not prime. This cannot go on forever because the integers we produce are decreasing and each factorization gives strictly smaller numbers: the process eventually stops with a product of primes.

\(Proof \,\, of \,\, the \,\, existence \,\, of \,\, the \,\, decomposition\) [Humphreys & Prest pp. 28-29]

Show by strong induction that every positive integer greater than or equal to \(2\) has a factorization as a product of primes.

Base Case

\(n = 2\) is prime.

For \(n \gt 2\) either \(n\) is prime in which case \(n\) has a factorization (with just one factor) of the required form or \(n\) can be written as a product \(ab\) where \(1 \lt a \lt n\) and \(1 \lt b \lt n\).

Induction Step

Induction Hypothesis: Let \(a\) and \(b\) both have factorizations into primes.
We obtain a factorization of \(n\) as a product of primes by juxtaposing the factorizations of \(a\) and \(b\).

Therefore every positive integer greater than or equal to \(2\) has a factorization as a product of primes.

\(\blacksquare\)

\(Examples\) [Humphreys & Prest pp. 29-30]

\[\begin{split} \begin{align*} 4 &= 2^2 \\ 6 &= 2^1 \times 3^1 \\ 8 &= 2^3 \\ &= (2) \times (2 \times 2) = 2 \times 4 \\ 9 &= 2^0 \times 3^2 \\ 10 &= 2^1 \times 3^0 \times 5^1 \\ 12 &= 2^2 \times 3^1 \\ &= (2) \times (2 \times 3) = 2 \times 6 \\ &= (2 \times 2) \times (3) = 4 \times 3 \\ 14 &= 2^1 \times 3^0 \times 5^0 \times 7^1 \\ 15 &= 2^0 \times 3^1 \times 5^1 \\ 16 &= 2^4 \\ &= (2) \times (2 \times 2 \times 2) = 2 \times 8 \\ &= (2 \times 2) \times (2 \times 2) = 4 \times 4 \\ 18 &= 2^1 \times 3^2 \\ &= (2) \times (3 \times 3) = 2 \times 9 \\ &= (2 \times 3) \times (3) = 6 \times 3 \\ 20 &= 2^2 \times 3^0 \times 5^1 \\ &= (2) \times (2 \times 5) = 2 \times 10 \\ &= (2 \times 2) \times (5) = 4 \times 5 \\ 21 &= 2^0 \times 3^1 \times 5^0 \times 7^1 \\ 22 &= 2^1 \times 3^0 \times 5^0 \times 7^0 \times 11^1 \\ 24 &= 2^3 \times 3^1 \\ &= (2) \times (2 \times 2 \times 3) = 2 \times 12 \\ &= (2 \times 2) \times (2 \times 3) = 4 \times 6 \\ &= (2 \times 2 \times 2) \times (3) = 8 \times 3 \\ 25 &= 2^0 \times 3^0 \times 5^2 \\ 26 &= 2^1 \times 3^0 \times 5^0 \times 7^0 \times 11^0 \times 13^1 \\ 28 &= 2^2 \times 3^0 \times 5^0 \times 7^1 \\ &= (2) \times (2 \times 7) = 2 \times 14 \\ &= (2 \times 2) \times (7) = 4 \times 7 \\ 30 &= 2^1 \times 3^1 \times 5^1 \\ &= (2) \times (3 \times 5) = 2 \times 15 \\ &= (2 \times 3) \times (5) = 6 \times 5 \\ \vdots \\ 72 &= 2^3 \times 3^2 \\ &= (2) \times (2 \times 2 \times 3 \times 3) = 2 \times 36 \\ &= (2 \times 2) \times (2 \times 3 \times 3) = 4 \times 18 \\ &= (2 \times 2 \times 2) \times (3 \times 3) = 8 \times 9 \\ &= (2 \times 2 \times 2 \times 3) \times (3) = 24 \times 3 \\ \vdots \\ 588 &= 2^2 \times 3^1 \times 5^0 \times 7^2 \\ &= (2) \times (2 \times 3 \times 7 \times 7) = 2 \times 294 \\ &= (3) \times (2 \times 2 \times 7 \times 7) = 3 \times 196 \\ &= (7) \times (2 \times 2 \times 3 \times 7) = 7 \times 84 \\ &= (2 \times 2) \times (3 \times 7 \times 7) = 4 \times 147 \\ &= (2 \times 3) \times (2 \times 7 \times 7) = 6 \times 98 \\ &= (2 \times 7) \times (2 \times 3 \times 7) = 14 \times 42 \\ &= (2 \times 2 \times 3) \times (7 \times 7) = 12 \times 49 \\ &= (2 \times 2 \times 7) \times (3 \times 7) = 28 \times 21 \\ \end{align*} \end{split}\]

This proof is based on the observation that if a prime divides one side of the equation then it divides the other, so we can cancel it from each side. This process eventually stops with the equation \(1 = 1\). Therefore there must have been the same number of primes, and indeed the same primes, on each side of the original equation.

\(Proof \,\, of \,\, uniqueness\) [Humphreys & Prest pp. 28-29]

Use the standard form of mathematical induction on the number \(r\) of prime factors to show that any positive integer which has a factorization into a product of \(r\) primes has a unique factorization up to rearrangement.

Base Case

Let \(n = q_1 q_2 \dots q_s\) be a prime.
If we had \(s \ge 2\) then \(n\) would have distinct divisors \(1, q_1, q_1q_2\) contradicting that it is prime.
Therefore \(s = 1\).

Induction Step

Induction Hypothesis: Any positive integer greater than \(2\) which has a factorization into \(r - 1\) primes has a unique factorization.
Let \(n = p_1 p_2 \dots p_r = q_1 q_2 \dots q_s\) be two prime factorizations of \(n\).
\(p_1\) divides \(n\) implies that \(p_1\) divides one of \(q_1, q_2, \dots, q_s\).
We can renumber the \(q_i\) so that it is \(q_1\) that \(p_1\) divides.
It must be the case that \(p_1 = q_1\) since both \(p_1\) and \(q_1\) are prime.
Therefore \(p_2 p_3 \dots p_r = q_2 q_3 \dots q_s\).
The integer \(p_2 p_3 \dots p_r\) is a product of \(r - 1\) primes.
Therefore \(r - 1 = s - 1 \iff r = s\) and after renumbering \(p_i = q_i\) for \(i = 2, \dots, r\).
Since we already have \(p_1 = q_1\) we have \(p_i = q_i\) for \(i = 1, 2, \dots, r\).

Therefore any positive integer has a unique factorization up to rearrangement.

\(\blacksquare\)


Claim: if \(n\) is a power of \(2\) then it has no odd divisors other than \(\pm 1\)#

CLAIM

If \(n\) is a power of \(2\) then \(n\) has no odd divisors other than \(\pm 1\).

\(\exists k \in \mathbb{N} \quad n = 2^k \quad \implies \quad \forall d \in \mathbb{Z} \quad d \ne \pm 1 \quad d \nmid n\)

PROOF

The fundamental theorem of arithmetic says that any positive integer \(n\) has a unique prime factorization

\( \begin{aligned} n = (\pm 1) \times 2^k \times \underbrace{p_1^{a_1} \times p_2^{a_2} \times \dotsb \times p_r^{a_r}}_{\text{odd prime factors}} = (\pm 1) \times 2^k \times \underset{\text{odd}}{m} \end {aligned} \)

where \(k \ge 0\) is the largest power of \(2\) that divides \(n\) and \(m = p_1^{a_1} p_2^{a_2} \dots p_r^{a_r}\) is an odd number

(all even factors are accounted for by \(2^k\), and a product of odd numbers is odd)

(and \(n = 1\) is the empty product of primes)

\(\blacksquare\)


Canonical representation of a positive integer#

Every positive integer \(n\) can be represented in exactly one way as a product of prime powers

\( \begin{aligned} n = p_1^{a_1} p_1^{a_2} \dots p_k^{a_k} = \prod_{i=1}^k p_i^{a_i} \end {aligned} \)

where \(2 \le p_1 \lt p_2 \lt \dots \lt p_k\) are primes and the \(a_i\) are positive integers.

\( \begin{aligned} k &&& n \\ 0 &&& 1 = \prod_{i=1}^0 p_i^{a_i} \\ 1 &&& 2 = p_1^{a_1} \\ \end {aligned} \)


\(\gcd(a, b) = \prod_{i=1}^k p_i^{\min(r_i, s_i)}\)#

Property of GCD

Suppose \(a\) and \(b\) are positive integers. Then by the fundamental theorem of arithmetic we can write

\(a = p_1^{r_1} \dots p_k^{r_k}\) and \(b = p_1^{s_1} \dots p_k^{s_k}\)

where \(p_1, \dotsc, p_k\) are the different primes in the factorization of \(a\) and \(b\) and we allow the possibility that the exponenets \(r_j, s_j\) may be zero. Then it is the case that

\(\gcd(a, b) = p_1^{\min(r_1, s_1)} \dots p_k^{\min(r_k, s_k)}\)

EXAMPLE

\( \begin{aligned} 20 &= p_1^2 p_2^0 p_3^1 = 2^2 \times 3^0 \times 5^1 \\ 75 &= p_1^0 p_2^1 p_3^2 = 2^0 \times 3^1 \times 5^2 \\ \gcd(20, 75) = 5 &= p_1^0 p_2^0 p_3^1 = 2^0 \times 3^0 \times 5^1 \\ \end {aligned} \)


\(\gcd(a^n, b^n) = \gcd(a, b)^n\)#

CLAIM

\(\gcd(a^n, b^n) = \gcd(a, b)^n\)

PROOF

Suppose \(a\) and \(b\) are positive integers with prime factorizations and GCD

\( \begin{array}{rcccc} a & = & (\pm 1) & \times & p_1^{r_1} & \times & p_2^{r_2} & \times & \dots & \times & p_k^{r_k} \\ b & = & (\pm 1) & \times & p_1^{s_1} & \times & p_2^{s_2} & \times & \dots & \times & p_k^{s_k} \\ \gcd(a, b) & = & & & p_1^{\min(r_1, s_1)} & \times & p_2^{\min(r_2, s_2)} & \times & \dots & \times & p_k^{\min(r_k, s_k)} \\ \end {array} \)

for some \(k \ge 1\).

Then for some \(n \ge 1\) we have

\( \begin{array}{rcccc} a^n & = & (\pm 1)^n & \times & p_1^{nr_1} & \times & p_2^{nr_2} & \times & \dots & \times & p_k^{nr_k} \\ b^n & = & (\pm 1)^n & \times & p_1^{ns_1} & \times & p_2^{ns_2} & \times & \dots & \times & p_k^{ns_k} \\ \gcd(a^n, b^n) & = & & & p_1^{\min(nr_1, ns_1)} & \times & p_2^{\min(nr_2, ns_2)} & \times & \dots & \times & p_k^{\min(nr_k, ns_k)} \\ \end {array} \)

\( \begin{aligned} \gcd(a^n, b^n) &= p_1^{\min(nr_1, ns_1)} p_2^{\min(nr_2, ns_2)} \dots p_k^{\min(nr_k, ns_k)} \\ &= p_1^{n \times \min(r_1, s_1)} p_2^{n \times \min(r_2, s_2)} \dots p_k^{n \times \min(r_k, s_k)} \\ &= \left( p_1^{\min(r_1, s_1)} p_2^{\min(r_2, s_2)} \dots p_k^{ \min(r_k, s_k)} \right)^n \\ &= \gcd(a, b)^n \end {aligned} \)

\(\blacksquare\)

Resources


LCM#

LEAST COMMON MULTIPLE

\( \begin{aligned} \text{lcm}[a, b] = \frac{ab}{\gcd(a, b)} = p_1^{\max(r_1, s_1)} \dots p_k^{\max(r_k, s_k)} \end {aligned} \)


Claim: \(\text{lcm}[a, b]\) is the smallest \(c\) with \(a \mid c\) and \(b \mid c\)#

Property of LCM

\(\text{lcm}[a, b]\) has the property that it is the smallest positive integer \(c\) so that \(a \mid c\) and \(b \mid c\).


GCD and LCM as prime factorizations#

\(Corollary\) [Humphreys & Prest 1.3.5 pp. 30-31]

Let \(a\) and \(b\) be positive integers.
Let \(a = p_1^{n_1} p_2^{n_2} \dots p_r^{n_r}\) and \(b = p_1^{m_1} p_2^{m_2} \dots p_r^{m_r}\) be the prime factorizations of \(a\) and \(b\) where \(p_1, p_2, \dots, p_r\) are distinct primes and \(n_1, n_2, \dots, n_r, m_1, m_2, \dots, m_r\) are non-negative integers (some perhaps zero in order to allow a common list of primes to be used).
Then the greatest common divisor \(d\) of \(a\) and \(b\) is given by \(d = p_1^{k_1} p_2^{k_2} \dots p_r^{k_r}\) where for each \(i\), \(k_i\) is the smaller of \(n_i\) and \(m_i\), and the least common multiple \(f\) of \(a\) and \(b\) is given by \(f = p_1^{t_1} p_2^{t_2} \dots p_r^{t_r}\) where for each \(i\), \(t_i\) is the larger of \(n_i\) and \(m_i\).

\(Examples\) [Humphreys & Prest pp. 31-32]

\(2\) and \(3\)

\[\begin{split} \begin{align*} a &= 2 &&= 2^1 \times 3^0 \\ b &= 3 &&= 2^0 \times 3^1 \\ \hline gcd(a, b) &= 1 &&= 2^0 \times 3^0 \\ lcm(a, b) &= 6 &&= 2^1 \times 3^1 \\ \end{align*} \end{split}\]

\(2\) and \(4\)

\[\begin{split} \begin{align*} a &= 2 &&= 2^1 \\ b &= 4 &&= 2^2 \\ \hline gcd(a, b) &= 2 &&= 2^1 \\ lcm(a, b) &= 4 &&= 2^2 \\ \end{align*} \end{split}\]

\(56\) and \(84\)

\[\begin{split} \begin{align*} a &= 56 &&= 2^3 \times 3^0 \times 7^1 \\ b &= 84 &&= 2^2 \times 3^1 \times 7^1 \\ \hline gcd(a, b) &= 28 &&= 2^2 \times 3^0 \times 7^1 \\ lcm(a, b) &= 168 &&= 2^3 \times 3^1 \times 7^1 \\ \end{align*} \end{split}\]

\(135\) and \(639\)

\[\begin{split} \begin{align*} a &= 135 &&= 3^3 \times 5^1 \times 71^0 \\ b &= 639 &&= 3^2 \times 5^0 \times 71^1 \\ \hline gcd(a, b) &= 9 &&= 3^2 \times 5^0 \times 71^0 \\ lcm(a, b) &= 9585 &&= 3^3 \times 5^1 \times 71^1 \\ \end{align*} \end{split}\]

Fermat Primes#

\(Claim\)

If \(2^n + 1\) is prime where \(n \ge 1\) then \(n\) must be of the form \(2^k\) for some positive integer \(k\).

\[\begin{split} \begin{align*} F(k) &= 2^{2^k} + 1 \\ F(0) &= 2^{2^0} + 1 = 3 && \text{prime} \\ F(1) &= 2^{2^1} + 1 = 5 && \text{prime} \\ F(2) &= 2^{2^2} + 1 = 17 && \text{prime} \\ F(3) &= 2^{2^3} + 1 = 257 && \text{prime} \\ F(4) &= 2^{2^4} + 1 = 65,537 && \text{prime} \\ F(5) &= 2^{2^5} + 1 = 4,294,967,297 && \text{composite} \\ F(6) &= 2^{2^6} + 1 = 18,446,744,073,709,551,617 && \text{composite} \\ \vdots \end{align*} \end{split}\]

Mersenne Primes#

\(Claim\)

If \(2^n - 1\) is prime then \(n\) is prime.

\[\begin{split} \begin{align*} M(n) &= 2^n - 1 \\ M(2) &= 2^2 - 1 = 3 && \text{prime} \\ M(3) &= 2^3 - 1 = 7 && \text{prime} \\ M(5) &= 2^5 - 1 = 31 && \text{prime} \\ M(7) &= 2^7 - 1 = 127 && \text{prime} \\ M(11) &= 2^{11} - 1 = 2,047 = 23 \times 89 && \text{composite} \\ M(13) &= 2^{13} - 1 = 8,191 && \text{prime} \\ M(17) &= 2^{17} - 1 = 131,071 && \text{prime} \\ M(19) &= 2^{19} - 1 = 524,287 && \text{prime} \\ M(23) &= 2^{23} - 1 = 8,388,607 = 47 × 178,481 && \text{composite} \\ M(29) &= 2^{29} - 1 = 536,870,911 = 233 × 1,103 × 2,089 && \text{composite} \\ M(31) &= 2^{31} - 1 = 2,147,483,647 && \text{prime} \\ M(37) &= 2^{37} - 1 = 137,438,953,471 = ? \times ? && \text{composite} \\ M(41) &= \\ M(43) &= \\ M(47) &= \\ M(53) &= \\ M(59) &= \\ M(61) &= \\ M(71) &= \\ M(73) &= \\ M(79) &= \\ M(83) &= \\ M(89) &= \\ M(97) &= \\ \vdots \\ M(13,466,917) &= 2^{13,466,917} - 1 = \text{4,000,000-digit integer (2001)} \\ \vdots \\ M(82,589,933) &= 2^{82,589,933} - 1 = \text{24,862,048-digit integer (2018)} \\ \end{align*} \end{split}\]

Goldbach’s Conjecture#

\(Conjecture\)

Every even number greater than two can be expressed as the sum of two primes.

\[ \forall n \in \mathbb{P} \,\, [\,\, (Even(n) \land (n \gt 2)) \implies \exists p, q \in \mathbb{P} \,\, [\,\, Prime(p) \land Prime(q) \land (n = p + q) \,\,] \,\,] \]

\(Examples\)

\(4 = 2 + 2\) is the only even integer greater than \(2\) which is the sum of the prime \(2\) and another prime (in this case, \(2\) too).

\[\begin{split} \begin{array}{c|c|c|c|c|c|c|c|c|c|c} 6 =& 3 \\ \hline 8 =& 3 & 5 \\ \hline 10 =& & 5 \\ \hline 12 =& & 5 & 7 \\ \hline 14 =& & & 7 \\ \hline 16 =& 3 & & & & 13 \\ \hline & & 5 & & 11 \\ \hline 18 =& & 5 & & & 13 \\ \hline & & & 7 & 11 \\ \hline 20 =& 3 & & & & & 17 \\ \hline & & & 7 & & 13 \\ \hline 22 =& 3 & & & & & & 19 \\ \hline & & 5 & & & & 17 \\ \hline & & & & 11 \\ \hline 24 =& & 5 & & & & & 19 \\ \hline & & & 7 & & & 17 \\ \hline & & & & 11 & 13 \\ \hline 26 =& 3 & & & & & & & 23 \\ \hline & & & 7 & & & & 19 \\ \hline & & & & & 13 \\ \hline 28 =& & 5 & & & & & & 23 \\ \hline & & & & 11 & & 17 \\ \hline 30 =& & & 7 & & & & & 23 \\ \hline & & & & 11 & & & 19 \\ \hline & & & & & 13 & 17 \\ \hline \end{array} \end{split}\]

Twin Primes Conjecture#

There are infinitely many pairs \((x, y)\) s.t. \(x\) and \(y\) are both prime and \(y = x + 2\).

\[\begin{split} \color{red} \begin{aligned} & \forall x, y \in \mathbb{P} \,\, (TwinPrimes(x, y) \iff (Prime(x) \land Prime(y) \land (y = x + 2))) \\ & \forall x, y \in \mathbb{P} \,\, (TwinPrimes(x, y) \implies \exists a, b \in \mathbb{P} \,\, ((a \gt x) \land TwinPrimes(a, b))) \end{aligned} \end{split}\]

Bounded Gap Theorem#

There are infinitely many pairs of primes that differ by at most \(70,000,000\).

\[\begin{split} \color{red} \begin{aligned} & \forall x, y \in \mathbb{P} \,\, (BoundedGapPrimes(x, y) \iff (Prime(x) \land Prime(y) \land (abs(y - x) \le 70,000,000))) \\ & \forall x, y \in \mathbb{P} \,\, (BoundedGapPrimes(x, y) \implies \exists a, b \in \mathbb{P} \,\, ((a \gt x) \land BoundedGapPrimes(a, b))) \end{aligned} \end{split}\]



Trial Division#

The simplest way to try to factorize a number \(n\) is by trial division.

TRIAL DIVISION

If \(n\) has a proper divisor \(m_1\) so that \(n = m_1 m_2\) with \(1 \lt m_1 \lt n\) whence \(1 \lt m_2 \lt n\) then it can be supposed that

\(m_1 \le m_2 \iff m_1 m_1 \le m_1 m_2 = n \iff m_1 \le \sqrt{n}\)

Thus each \(m_1 \le \sqrt{n}\) can be tried in turn. If no such factor is found then \(n\) is prime. Since the smallest proper divisor of \(n\) has to be the smallest prime factor of \(n\) we need only check the primes \(p\) with \(2 \le p \le \sqrt{n}\).

Even so, for large \(n\) this is hugely expensive in time. How to verify this?


Prime-Counting Function#

The number \(\pi(x)\) of primes \(p \le x\) is approximately

\( \begin{aligned} \pi(x) \sim \int_2^x \frac{d \alpha}{\ln \alpha} \sim \frac{x}{\ln x} \end {aligned} \)

Thus if \(n\) is about \(k\) bits in size and turns out to be prime or the product of two primes of about the same size, then the number of operations will be

\( \begin{aligned} \approx \frac{(2^{k/2})}{\ln (2^{k/2})} = \frac{2^{k/2}}{k/2 \ln 2} \end {aligned} \)

which is still exponential in the bit size.

Trial division is feasible for \(n\) out to about \(40\) bits on a modern computer; much beyond that it becomes hopeless. One area where trial division, or sophisticated variants thereor, are useful is in the production of tables of primes, or counts of primes such as the value of \(\pi(x)\).

Some values of the prime-counting function

\( \begin{aligned} \pi( 2) &=& 1 \\ \pi( 3) &=& 2 \\ \pi( 5) &=& 3 \\ \pi( 7) &=& 4 \\ \pi(10) &=& 4 \\ \pi(11) &=& 5 \\ \pi(13) &=& 6 \\ \pi(17) &=& 7 \\ \pi(19) &=& 8 \\ \pi(23) &=& 9 \\ \pi(29) &=& 10 \\ \pi(31) &=& 11 \\ \pi(37) &=& 12 \\ \pi(41) &=& 13 \\ \pi(43) &=& 14 \\ \pi(47) &=& 15 \\ \pi(53) &=& 16 \\ \pi(59) &=& 17 \\ \pi(61) &=& 18 \\ \pi(67) &=& 19 \\ \pi(71) &=& 20 \\ \pi(10^2) &=& \\ \pi(2^{16}) &=& 6542 \\ \end {aligned} \)

import math

print(f'x = 2^ 2     x/ln(x) = {2** 2/(math.log(2) *  2):>10.2f} {"π(2^ 2) =    2":>20}')
print(f'x = 2^ 3     x/ln(x) = {2** 3/(math.log(2) *  3):>10.2f} {"π(2^ 3) =    4":>20}')
print(f'x = 10       x/ln(x) = {10/(math.log(10)):>10.2f} {"π(10) =    4":>20}')
print(f'x = 2^ 4     x/ln(x) = {2** 4/(math.log(2) *  4):>10.2f} {"π(2^ 4) =    7":>20}')
print(f'x = 2^ 5     x/ln(x) = {2** 5/(math.log(2) *  5):>10.2f} {"π(2^ 5) =     ":>20}')
print(f'x = 2^ 6     x/ln(x) = {2** 6/(math.log(2) *  6):>10.2f} {"π(2^ 6) =     ":>20}')
print(f'x = 2^ 7     x/ln(x) = {2** 7/(math.log(2) *  7):>10.2f} {"π(2^ 7) =     ":>20}')
print(f'x = 2^ 8     x/ln(x) = {2** 8/(math.log(2) *  8):>10.2f} {"π(2^ 8) =     ":>20}')
print(f'x = 2^ 9     x/ln(x) = {2** 9/(math.log(2) *  9):>10.2f} {"π(2^ 9) =     ":>20}')
print(f'x = 2^10     x/ln(x) = {2**10/(math.log(2) * 10):>10.2f} {"π(2^10) =     ":>20}')
print(f'x = 2^11     x/ln(x) = {2**11/(math.log(2) * 11):>10.2f} {"π(2^11) =     ":>20}')
print(f'x = 2^12     x/ln(x) = {2**12/(math.log(2) * 12):>10.2f} {"π(2^12) =     ":>20}')
print(f'x = 2^13     x/ln(x) = {2**13/(math.log(2) * 13):>10.2f} {"π(2^13) =     ":>20}')
print(f'x = 2^14     x/ln(x) = {2**14/(math.log(2) * 14):>10.2f} {"π(2^14) =     ":>20}')
print(f'x = 2^15     x/ln(x) = {2**15/(math.log(2) * 15):>10.2f} {"π(2^15) =     ":>20}')
print(f'x = 2^16     x/ln(x) = {2**16/(math.log(2) * 16):>10.2f} {"π(2^16) = 6542":>20}')
x = 2^ 2     x/ln(x) =       2.89       π(2^ 2) =    2
x = 2^ 3     x/ln(x) =       3.85       π(2^ 3) =    4
x = 10       x/ln(x) =       4.34         π(10) =    4
x = 2^ 4     x/ln(x) =       5.77       π(2^ 4) =    7
x = 2^ 5     x/ln(x) =       9.23       π(2^ 5) =     
x = 2^ 6     x/ln(x) =      15.39       π(2^ 6) =     
x = 2^ 7     x/ln(x) =      26.38       π(2^ 7) =     
x = 2^ 8     x/ln(x) =      46.17       π(2^ 8) =     
x = 2^ 9     x/ln(x) =      82.07       π(2^ 9) =     
x = 2^10     x/ln(x) =     147.73       π(2^10) =     
x = 2^11     x/ln(x) =     268.60       π(2^11) =     
x = 2^12     x/ln(x) =     492.44       π(2^12) =     
x = 2^13     x/ln(x) =     909.12       π(2^13) =     
x = 2^14     x/ln(x) =    1688.37       π(2^14) =     
x = 2^15     x/ln(x) =    3151.62       π(2^15) =     
x = 2^16     x/ln(x) =    5909.28       π(2^16) = 6542



Sieve of Eratosthenes#

Trial division, or its sophisticated variants, is useful in the production of tables of primes or counts of primes (such as the value of the prime-counting function). The sieve of Eratosthenes is the simplest form of this.

[Humphreys & Prest pp. 26]

To find the primes less than some number \(n\), prepare an array of the integers from \(2\) to \(n\). Save \(2\) and then delete all multiples of \(2\). Now look for the next undeleted integer (which will be \(3\)), save it and delete all its multiples. The smallest undeleted number will be the next prime, \(5\). Continue in this way to find all the primes up to \(n\). In fact, it will turn out that you can stop this process once you have reached the greatest integer which is less than or equal to the square root of \(n\), in the sense that any integers left undeleted at this stage will be prime.

Construct a \(\lfloor \sqrt{N} \rfloor \times \lfloor \sqrt{N} \rfloor\) array. Here \(N = 100\).

\( \begin{matrix*}[r] 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\ 10 & 11 & 12 & 13 & 14 & 15 & 16 & 17 & 18 & 19 \\ 20 & 21 & 22 & 23 & 24 & 25 & 26 & 27 & 28 & 29 \\ 30 & 31 & 32 & 33 & 34 & 35 & 36 & 37 & 38 & 39 \\ 40 & 41 & 42 & 43 & 44 & 45 & 46 & 47 & 48 & 49 \\ 50 & 51 & 52 & 53 & 54 & 55 & 56 & 57 & 58 & 59 \\ 60 & 61 & 62 & 63 & 64 & 65 & 66 & 67 & 68 & 69 \\ 70 & 71 & 72 & 73 & 74 & 75 & 76 & 77 & 78 & 79 \\ 80 & 81 & 82 & 83 & 84 & 85 & 86 & 87 & 88 & 89 \\ 90 & 91 & 92 & 93 & 94 & 95 & 96 & 97 & 98 & 99 \\ \end {matrix*} \)

Forget about \(0\) and \(1\) and then for each successive element remaining remove the proper multiples.

For \(2\) we remove \(4, 6, \dotsc, 98\).

\( \begin{matrix*}[r] \phantom{00} & & 2 & 3 & \phantom{00} & 5 & \phantom{00} & 7 & \phantom{00} & 9 \\ & 11 & \phantom{00} & 13 & & 15 & & 17 & & 19 \\ & 21 & & 23 & & 25 & & 27 & & 29 \\ & 31 & & 33 & & 35 & & 37 & & 39 \\ & 41 & & 43 & & 45 & & 47 & & 49 \\ & 51 & & 53 & & 55 & & 57 & & 59 \\ & 61 & & 63 & & 65 & & 67 & & 69 \\ & 71 & & 73 & & 75 & & 77 & & 79 \\ & 81 & & 83 & & 85 & & 87 & & 89 \\ & 91 & & 93 & & 95 & & 97 & & 99 \\ \end {matrix*} \)

For the next remaining element \(3\) remove \(6, 9, \dotsc, 99\).

\( \begin{matrix*}[r] \phantom{00} & & 2 & 3 & \phantom{00} & 5 & \phantom{00} & 7 & \phantom{00} & \\ & 11 & \phantom{00} & 13 & & & & 17 & & 19 \\ & & & 23 & & 25 & & & & 29 \\ & 31 & & & & 35 & & 37 & & \\ & 41 & & 43 & & & & 47 & & 49 \\ & & & 53 & & 55 & & & & 59 \\ & 61 & & & & 65 & & 67 & & \\ & 71 & & 73 & & & & 77 & & 79 \\ & & & 83 & & 85 & & & & 89 \\ & 91 & & & & 95 & & 97 & & \\ \end {matrix*} \)

For the next remaining element \(5\) remove \(10, 15, \dotsc, 95\).

\( \begin{matrix*}[r] \phantom{00} & & 2 & 3 & \phantom{00} & 5 & \phantom{00} & 7 & \phantom{00} & \\ & 11 & \phantom{00} & 13 & & \phantom{00} & & 17 & & 19 \\ & & & 23 & & & & & & 29 \\ & 31 & & & & & & 37 & & \\ & 41 & & 43 & & & & 47 & & 49 \\ & & & 53 & & & & & & 59 \\ & 61 & & & & & & 67 & & \\ & 71 & & 73 & & & & 77 & & 79 \\ & & & 83 & & & & & & 89 \\ & 91 & & & & & & 97 & & \\ \end {matrix*} \)

For the next remaining element \(7\) remove \(14, 21, \dotsc, 98\).

\( \begin{matrix*}[r] \phantom{00} & & 2 & 3 & \phantom{00} & 5 & \phantom{00} & 7 & \phantom{00} & \\ & 11 & \phantom{00} & 13 & & \phantom{00} & & 17 & & 19 \\ & & & 23 & & & & & & 29 \\ & 31 & & & & & & 37 & & \\ & 41 & & 43 & & & & 47 & & \\ & & & 53 & & & & & & 59 \\ & 61 & & & & & & 67 & & \\ & 71 & & 73 & & & & & & 79 \\ & & & 83 & & & & & & 89 \\ & & & & & & & 97 & & \\ \end {matrix*} \)

After that the next remaining element is \(11\) and for that and its successors all the proper multiples have already been removed. Thus we now have a table of all the primes \(p \le 100\).

This is relatively efficient.

By counting the entries that remain one finds that \(\pi(100) = 25\).

The sieve of Eratosthenes produces approximately

\( \begin{aligned} \frac{n}{\log n} \end {aligned} \)

numbers in about

\( \begin{aligned} \sum_{p \le \sqrt{n}} \frac{n}{p} \sim n \log \log n \end {aligned} \)

operations.

Another big constraint is storage.




Fermat Factorization#

Here is an idea that goes back to Fermat.

Given \(n\) suppose we can find \(x\) and \(y\) so that

\(n = x^2 - y^2\) with \(0 \le y \lt x\).

There may be a way of factoring \(n\) since the polynomial factorizes as \((x - y)(x + y)\).

We are only likely to try this if \(n\) is odd, say \(n = 2k + 1\), and then we might run into

\(n = 2k + 1 = \underbrace{(k + 1)^2}_{x^2} - \underbrace{\phantom{( + 1)}k^2}_{\, y^2 \,} = 1 \times (2k + 1)\)

which does not help much.

If \(n\) is prime then perforce \(x - y = 1\) and \(x + y = 2k + 1\) and this is the only solution.

If we can find a solution with \(x - y \gt 1\) then that would show that \(n\) is composite and would give a factorization.

If \(n = m_1 m_2\) with \(n\) odd and \(m_1 \le m_2\) then \(m_1\) and \(m_2\) are both odd and there is a solution with

\( \begin{aligned} x - y &= m_1 \\ x + y &= m_2 \\ \end {aligned} \)

\( \begin{aligned} x &= \frac{m_1 + m_2}{2} \\ y &= \frac{m_2 - m_1}{2} \\ \end {aligned} \)

Example

\( \begin{aligned} n & &&= x^2 - y^2 &&& x && y && m_1 && m_2 \\ 91 &= 100 - 9 &&= 10^2 - 3^2 &&& 10 && 3 && 7 && 13 & = 7 \times 13 \\ 1001 &= 2025 - 1024 &&= 45^2 - 32^2 &&& 45 && 32 && 13 && 77 & = 7 \times 11 \times 13 \\ \end {aligned} \)

This method has the downside that

\(x^2 = n + y^2\)

so already one is searching among \(x\) which are greater than \(\sqrt{n}\) and one could end up searching among that many possibilities. The chances of solving this easily for large \(n\) are quite small. Nevertheless, this is a fruitful idea. For example, suppose instead of \(n = x^2 - y^2\) we could solve

\(x^2 - y^2 = kn\)

for a relatively small value of \(k\). It is not very likely that \(x - y\) or \(x + y\) are factors of \(n\), but if we could compute

\(g = \gcd(x + y, n)\)

then we might find that \(g\) differs from \(1\) or \(n\) and so gives a factorization.

Moreover, there is a very fast way of computing GCD.

Example

\( \begin{aligned} n && k && kn & &&= x^2 - y^2 && x - y && x + y && \gcd(x + y, n) \\ 10001 && 8 && 80008 &= 80089 - 81 &&= 283^2 - 9^2 && 274 && 291 && \gcd(291, 10001) = 73 && 10001 = 73 \times 137 \\ \end {aligned} \)




Euclid’s Algorithm#


Given integers \(a\) and \(b\) not both zero there are integers \(x\) and \(y\) such that

\(\gcd(a, b) = ax + by\)

How do we find \(x\) and \(y\)?

Euclid’s algorithm gives a very efficient algorithm, and is still the basis for many numerical methods in arithmetical applications (e.g., factorization routines).

EUCLID’S ALGORITHM

We may suppose that both \(a \gt 0\) and \(b \gt 0\) since multiplying either by \(-1\) does not change \(\gcd(a, b)\): we can replace \(x\) by \(-x\) and \(y\) by \(-y\).

We may also suppose that \(b \le a\) (and in practice that \(b \lt a\)).

For convenience of notation put \(r_0 = b\) and \(r_{-1} = a\).

Apply the division algorithm iteratively as follows.

\( \begin{aligned} r_{-1} &= r_0 q_1 + r_1 && 0 \lt r_1 \le r_0 \\ r_0 &= r_1 q_2 + r_2 && 0 \lt r_2 \lt r_1 \\ r_1 &= r_2 q_3 + r_3 && 0 \lt r_3 \lt r_2 \\ \vdots \\ r_{s-3} &= r_{s-2} q_{s-1} + r_{s-1} && 0 \lt r_{s-1} \lt r_{s-2} \\ r_{s-2} &= r_{s-1} q_s \\ \end {aligned} \)

That is, we stop the moment there is a remainder equal to \(0\). This could be \(r_1\) if \(b \mid a\), for example. (Although the way it is written out above it is as if \(s\) is at least \(3\).)

The important point is that since \(r_j \lt r_{j-1}\) we must eventually have a zero remainder.

\( \boxed{ } \)

Euclid proved that \(\gcd(a, b) = r_{s-1}\).

Proof

\( \begin{array}{ll} \gcd(a, b) \mid a & = r_{-1} \\ \gcd(a, b) \mid b & = r_{\phantom{-}0} \\ \gcd(a, b) \mid r_1 & = r_{-1} - r_0 q_1 \\ \gcd(a, b) \mid r_2 & = r_{\phantom{-}0} - r_1 q_2 \\ \vdots \\ \gcd(a, b) \mid r_{s-1} & = r_{s-3} - r_{s-2} q_{s-1} \end {array} \)

We can see that \(\gcd(a, b) \mid r_j\) for \(j = 2, 3, \dotsc, s - 2, s - 1\).

Starting from the bottom, \(r_{s-1} \mid r_{s-2}\), \(r_{s-1} \mid r_{s-3}\), and so on until we have \(r_{s-1} \mid b\) and \(r_{s-1} \mid a\), and so \(r_{s-1} \mid \gcd(a, b)\).

Since \(r_{s-1} \mid \gcd(a, b)\) and \(\gcd(a, b) \mid r_{s-1}\) it is the case that \(r_{s-1} = \gcd(a, b)\).

\(\blacksquare\)

Example

\( \begin{aligned} a &= & 10,678 \\ b &= & 42 \\ 10,678 &= & 42 &\times & 254 &+ & 10 \\ 42 &= & 10 &\times & 4 &+ & 2 \\ 10 &= & 2 &\times & 5 \\ \end {aligned} \)

\(\gcd(10678, 42) = 2\)

\(x\) and \(y\) can be found via back substitution, which is inefficient since it requires that computations be stored.

\( \begin{aligned} 2 &= 42 - 10 \times 4 \\ &= 42 - (10,678 - 42 \times 254) \times 4 \\ &= 42 - 10,678 \times 4 + 42 \times 254 \times 4 \\ &= 42 + 42 \times 254 \times 4 - 10,678 \times 4 \\ &= 42 \times (1 + 254 \times 4) - 10,678 \times 4 \\ &= 42 \times 1017 - 10,678 \times 4 \\ \end {aligned} \)


Extended Euclidean Algorithm#

EXTENDED EUCLIDEAN ALGORITHM

Define

\( \begin{aligned} r_{-1} &:= a \\ r_0 &:= b \\ x_{-1} &:= 1 \\ x_0 &:= 0 \\ y_{-1} &:= 0 \\ y_0 &:= 1 \\ \end {aligned} \)

and then lay out the calculations as follows.

\( \begin{aligned} r_{-1} &= r_0 q_1 + r_1 && x_1 = x_{-1} - q_1 x_0 && y_1 = y_{-1} - q_1 y_0 \\ r_0 &= r_1 q_2 + r_2 && x_2 = x_0 - q_2 x_1 && y_2 = y_0 - q_2 y_1 \\ r_1 &= r_2 q_3 + r_3 && x_3 = x_1 - q_3 x_2 && y_3 = y_1 - q_3 y_2 \\ \vdots \\ r_{s-3} &= r_{s-2} q_{s-1} + r_{s-1} && x_{s-1} = x_{s-3} - q_{s-1} x_{s-2} && y_{s-1} = y_{s-3} - q_{s-1} y_{s-2} \\ r_{s-2} &= r_{s-1} q_s \\ \end {aligned} \)

The claim is that

\(x = x_{s-1}, y = y_{s-1}\)

More generally, the claim is that

\(r_j = ax_j + by_j\)

and this can be proved by induction.

Proof by induction on \(j\)

Basis

By construction it is the case that \(r_{-1} = ax_{-1} + by_{-1}\) and \(r_0 = ax_0 + by_0\).

\( \begin{aligned} r_{-1} &= a \times 1 + b \times 0 = a \\ r_0 &= a \times 0 + b \times 1 = b \\ \end {aligned} \)

Induction Step

Suppose \(r_k = ax_k + by_k\) is established for all \(j \le k\).

\( \begin{aligned} r_{k+1} &= r_{k-1} - q_{k+1} r_k \\ &= (ax_{k-1} + by_{k-1}) - q_{k+1} (ax_k + by_k) \\ &= ax_{k-1} + by_{k-1} - q_{k+1} ax_k - q_{k+1} by_k \\ &= ax_{k-1} - q_{k+1} ax_k + by_{k-1} - q_{k+1} by_k \\ &= a(x_{k-1} - q_{k+1} x_k) + b(y_{k-1} - q_{k+1} y_k) \\ &= ax_{k+1} + by_{k+1} \\ \end {aligned} \)

\(\boxed{\gcd(a, b) = r_{s-1} = ax_{s-1} + by_{s-1}}\)

\(\blacksquare\)

Example

EXAMPLE

\( \begin{aligned} r_{-1} &= & 10,678 \\ r_0 &= & 42 \\ x_{-1} &= & 1 \\ x_0 &= & 0 \\ y_{-1} &= & 0 \\ y_0 &= & 1 \\ 10,678 &= & 42 &\times & 254 &+ & 10 && \underset{x_1}{ 1} &= & 1 &- & 254 &\times & 0 && \underset{y_1}{-254} &= & 0 &- & 1 &\times & 254 \\ 42 &= & 10 &\times & 4 &+ & 2 && \underset{x_2}{-4} &= & 0 &- & 4 &\times & 1 && \underset{y_2}{1017} &= & 1 &- & 4 &\times & (-254) \\ 10 &= & 2 &\times & 5 \\ \end {aligned} \)

\(\gcd(10678, 42) = 2 = 10678 \times (-4) + 42 \times 1017\)




Linear Diophantine Equations#

Linear Diophantine Equation

Euclid’s algorithm can be used to find the complete solution in integers to linear diophantine equations of the kind

\(ax + by = c\) where \(a\), \(b\), and \(c\) are integers, and \(x\) and \(y\) are all integers which satisfy this

\(\text{Case 1}\) Both \(a\) and \(b\) are zero. —– If \(a = b = 0\) then the linear diophantine equation is not soluble unless \(c = 0\); and then it is soluble by any \(x\) and \(y\), which is not very interesting.

\(\text{Case 2}\) One of \(a\) and \(b\) is non-zero.

\(\gcd(a, b) \mid (ax + by) \implies \gcd(a, b) \mid c\)

Choose \(x\) and \(y\) s.t. \(ax + by = \gcd(a, b)\). Then there is a solution

\( \begin{aligned} ax + by &= \gcd(a, b) \\ \frac{ax + by}{\gcd(a, b)} &= 1 \\ c \frac{ax + by}{\gcd(a, b)} &= c \\ a \left( \frac{xc}{\gcd(a, b)} \right) + b \left( \frac{yc}{\gcd(a, b)} \right) \end {aligned} \)

Let’s call this solution \(x_0, y_0\). Consider any other solution \(x, y\).

\( \begin{aligned} ax + by &= c \\ ax + by - ax_0 - by_0 &= c - c = 0 \\ ax - ax_0 &= by_0 - by \\ a(x - x_0) &= b(y_0 - y) \\ \frac{a}{\gcd(a, b)}(x - x_0) &= \frac{b}{\gcd(a, b)}(y_0 - y) \\ \end {aligned} \)

Recall that \(\gcd \left( \frac{a}{\gcd(a, b)}, \frac{b}{\gcd(a, b)} \right) = 1\)

\(y_0 - y = z \frac{a}{\gcd(a, b)}\) for some \(z\)

\(x - x_0 = z \frac{b}{\gcd(a, b)}\) for some \(z\)

Any \(x\) and \(y\) of this form give a solution, so we have found a complete solution set.

THEOREM

Suppose that \(a\) and \(b\) are not both zero, that \(\gcd(a, b) \mid c\), and that \(ax_0 + by_0 = c\). Then every solution of

\(ax + by = c\)

is given by

\(x = x_0 + z \frac{b}{\gcd(a, b)}, y = y_0 + z \frac{a}{\gcd(a, b)}\)

where \(z\) is any integer.

The solutions \(x\) all leave the same remainder on division by \(\frac{b}{\gcd(a, b)}\) and likewise for \(y\) on division by \(\frac{a}{\gcd(a, b)}\).




Lehman’s Method#

Lehman’s method is based on differences of squares and is a small improvement over trial division.

LEHMAN’S METHOD [Vaughan Algorithm 2.2]

1. Apply trial division with \(d = 2, 3, \dotsc, d \le n^{\frac{1}{3}}\)

2. For \(1 \le t \le n^{\frac{1}{3}} + 1\) consider the numbers \(x\) with

\(\sqrt{4tn} \le x \le \sqrt{4tn + n^{\frac{2}{3}}}\)

Check each \(x^2 - 4tn\) to see if it is a perfect square \(y^2\) (compute \(4tn - \left\lfloor \sqrt{4tn} \right\rfloor^2\))

3. If there are \(x\) and \(y\) such that \(x^2 - 4tn = y^2\) then compute \(\gcd(x + y, n)\).

4. If there is no \(t \le n^{\frac{1}{3}} + 1\) for which there are \(x\) and \(y\), then \(n\) is prime.

Proof

The proof depends on a subject called Diophantine approximation, via continued fractions, which in turn has some connections with Euclid’s algorithm. We can take a shortcut via Dirichlet (below).

https://www.ams.org/journals/mcom/1974-28-126/S0025-5718-1974-0340163-2/S0025-5718-1974-0340163-2.pdf

Example

\(n = 10001\) and so \(\lfloor n^{\frac{1}{3}} \rfloor = 21\)

\(21^3 \lt 10000 \lt 22^3\)

1. Trial division with \(d = 2, 3, 5, 7, 11, 13, 17, 19\) finds no factors.

2. For \(1 \le t \le 22\) consider the numbers \(x\) with

\(\left\lceil \sqrt{40004t} \right\rceil \le x \le \left\lfloor \sqrt{40004t + \underset{441}{21}^2} \right\rfloor\)

\( \begin{aligned} t &= 1 \\ 4tn &= 40004 \\ \left\lceil \sqrt{4tn} \right\rceil &= 201 \\ \left\lfloor \sqrt{4tn + n^{\frac{2}{3}}} \right\rfloor &= \left\lfloor \sqrt{\underbrace{40004 + 441}_{40445}} \right\rfloor = 201 \\ \end {aligned} \)

\( \begin{aligned} 4tn - \left\lfloor \sqrt{4tn} \right\rfloor^2 &= 40004 - \underset{40004}{200}^2 = 4 = 2^2 \\ x^2 - 4tn &= \underset{40401}{201}^2 - 40004 = 397 \\ \end {aligned} \)

\( \begin{aligned} t &= 2 \\ 4tn &= 80008 \\ \left\lceil \sqrt{4tn} \right\rceil &= 283 \\ \left\lfloor \sqrt{4tn + n^{\frac{2}{3}}} \right\rfloor &= \left\lfloor \sqrt{\underbrace{80008 + 441}_{80449}} \right\rfloor = 283 \\ \end {aligned} \)

\( \begin{aligned} 4tn - \left\lfloor \sqrt{4tn} \right\rfloor^2 &= 80008 - \underset{79524}{282}^2 = 484 = 22^2 \\ x^2 - 4tn &= \underset{80089}{283}^2 - 80008 = 81 = 9^2 \\ \end {aligned} \)

\(\gcd(x + y, n) = \gcd(283 + 9, 10001) = 73\)

from decimal import *
getcontext().prec = 50

n = 10001
for t in [1,2]:
  tn4 = 4*t*n
  print(f"(4tn)^(1/2)           {str(Decimal(tn4)**(Decimal(1)/Decimal(2)))}")
  print(f"(4tn + n^(2/3))^(1/2) {str(Decimal(tn4 + n**(Decimal(2)/Decimal(3)))**(Decimal(1)/Decimal(2)))}")
  print()
(4tn)^(1/2)           200.00999975001249921880468339875973944309979013137
(4tn + n^(2/3))^(1/2) 201.16706943923780820782055420590837397530737200471

(4tn)^(1/2)           282.85685425670702668230465161705172548037581530420
(4tn + n^(2/3))^(1/2) 283.67620595808018197598741952851738922420698676761

Dirichlet’s Theorem#

DIRICHLET’S APPROXIMATION THEOREM [Vaughan Theorem 2.2]

For any real number \(\alpha\) and any integer \(Q \ge 1\) there exist integers \(a\) and \(q\) with \(1 \le q \le Q\) such that

\( \begin{aligned} \left| \alpha - \frac{a}{q} \right| \le \frac{1}{q(Q + 1)} \lt \frac{1}{qQ} \quad \iff \quad \left| q\alpha - a \right| \le \frac{1}{Q + 1} \lt \frac{1}{Q} \end {aligned} \)

As an immediate consequence of casting out all common factors of \(a\) and \(q\) in \(a/q\) we have

COROLLARY [Vaughan Corollary 2.3]

The conclusion holds with the additional condition \(\gcd(a, q) = 1\).

Proof

\(\blacksquare\)

Proof of Lehman’s Method#

LEHMAN’S METHOD PROOF

Proof

We must show that if there is a divisor \(d\) of \(n\) with

\(n^{\frac{1}{3}} \lt d \le n^{\frac{1}{2}}\)

then there is a \(t\) with

\(1 \le t \le n^{\frac{1}{3}} + 1\)

and an \(x\) and \(y\) such that

\(4tn \le x^2 \le 4tn + n^{\frac{2}{3}}\)

\(x^2 - y^2 = 4tn\)

We use Dirichlet’s theorem with

\( \begin{aligned} \alpha &= \frac{n}{d^2} \\ Q &= \left\lfloor \frac{d}{n^{\frac{1}{3}}} \right\rfloor \\ \end {aligned} \)

Since \(d \gt n^{\frac{1}{3}}\) we have

\( \begin{aligned} Q = \left\lfloor \frac{d}{n^{\frac{1}{3}}} \right\rfloor \gt 1 \end {aligned} \)

Thus we know that there are \(a \in \mathbb{Z}\) and \(q \in \mathbb{N}\) such that \(1 \le q \le Q\) and

\( \begin{aligned} \left| \frac{n}{d^2} - \frac{a}{q} \right| \le \frac{1}{q(Q + 1)} \lt \frac{n^{\frac{1}{3}}}{qd} \quad \iff \quad \left| \frac{n}{d}q - ad \right| \lt n^{\frac{1}{3}} \end {aligned} \)

We know from a property of the floor function that

\( \begin{aligned} 0 \le \frac{d}{n^{\frac{1}{3}}} - Q \lt 1 & \quad \iff \quad Q \le \frac{d}{n^{\frac{1}{3}}} \lt Q + 1 \\ & \quad \iff \quad Qn^{\frac{1}{3}} \le d \lt (Q + 1)n^{\frac{1}{3}} \\ & \quad \iff \quad \frac{d}{Q + 1} \lt n^{\frac{1}{3}} \\ & \quad \iff \quad \frac{1}{Q + 1} \lt \frac{n^{\frac{1}{3}}}{d} \\ & \quad \iff \quad \frac{1}{q(Q + 1)} \lt \frac{n^{\frac{1}{3}}}{qd} \\ \end {aligned} \)

It is also the case that

\( \begin{array}{cccccc} & Q & \le & \frac{d}{n^{\frac{1}{3}}} & \iff & \frac{Qn^{\frac{1}{3}}}{d} & \le 1 & \iff & \frac{n^{\frac{1}{3}}}{d} & \le & \frac{1}{Q} \\ & \frac{d}{n^{\frac{1}{3}}} & \lt & Q + 1 & \iff & \frac{d}{n^{\frac{1}{3}}(Q + 1)} & \lt 1 & \iff & \frac{1}{Q + 1} & \lt & \frac{n^{\frac{1}{3}}}{d} \\ \end {array} \)

Thus

\( \begin{aligned} \frac{1}{Q + 1} \lt \frac{n^{\frac{1}{3}}}{d} \le \frac{1}{Q} \end {aligned} \)

Let

\( \begin{aligned} x &= \phantom{|} \frac{n}{d}q + ad \\ y &= \left| \frac{n}{d}q - ad \right| \\ t &= aq \\ \end {aligned} \)

Then

\( \begin{aligned} x^2 &= \left( \frac{n}{d}q + ad \right) \left( \frac{n}{d}q + ad \right) &= \frac{n^2}{d^2}q^2 + 2nqa + a^2d^2 \\ y^2 &= \left| \frac{n}{d}q - ad \right| \left| \frac{n}{d}q - ad \right| &= \frac{n^2}{d^2}q^2 - 2nqa + a^2d^2 \\ &= x^2 + 4tn \\ \end {aligned} \)

Moreover

\( \begin{aligned} \left| \frac{n}{d}q - ad \right| = y \lt n^{\frac{1}{3}} \quad \iff \quad y^2 \lt n^{\frac{2}{3}} \end {aligned} \)

and

\( \begin{aligned} t = aq \lt \frac{n}{d^2}q^2 + n^{\frac{1}{3}} \frac{q}{d} \le \frac{n}{d^2}Q^2 + n^{\frac{1}{3}} \frac{Q}{d} \le n^{\frac{1}{3}} + 1 \end {aligned} \)

\( \begin{aligned} \left| \frac{n}{d}q - ad \right| \lt n^{\frac{1}{3}} \quad \iff \quad -n^{\frac{1}{3}} \lt \frac{n}{d}q - ad \lt n^{\frac{1}{3}} \quad \iff \quad ad - \frac{n}{d}q \lt n^{\frac{1}{3}} \quad \land \quad \frac{n}{d}q - ad \lt n^{\frac{1}{3}} \end {aligned} \)

\( \begin{aligned} & t = aq \lt \frac{n}{d^2}q^2 + n^{\frac{1}{3}} \frac{q}{d} = \frac{q}{d} \left( \frac{n}{d}q + n^{\frac{1}{3}} \right) \quad \iff \quad ad \lt \frac{n}{d}q + n^{\frac{1}{3}} \quad \iff \quad ad - \frac{n}{d}q \lt n^{\frac{1}{3}} \\ & t = aq \lt \frac{n}{d^2}q^2 + n^{\frac{1}{3}} \frac{q}{d} \le \frac{n}{d^2}Q^2 + n^{\frac{1}{3}} \frac{Q}{d} \le n^{\frac{1}{3}} + 1 \end {aligned} \)

We know that

\( \begin{aligned} Qn^{\frac{1}{3}} \le d \iff \frac{Qn^{\frac{1}{3}}}{d} \le 1 \end {aligned} \)

and so it follows that

\( \begin{aligned} \frac{n}{d^2}Q^2 + n^{\frac{1}{3}} \frac{Q}{d} = n^{\frac{1}{3}} \frac{Qn^{\frac{1}{3}}}{d} \frac{Qn^{\frac{1}{3}}}{d} + \frac{Qn^{\frac{1}{3}}}{d} \le n^{\frac{1}{3}} + 1 \end {aligned} \)

\(\blacksquare\)




Misc Proofs#


Finding last \(n\) digits of large integer#

The last \(n\) digits of a large base-10 integer \(N\) is

\(\equiv N \textbf{ mod } 10^n\)

What are the last two digits of \(3^{431}\)?

\(3^{\phi(10^2)} = 3^{\phi(2^2)\phi(5^2)} = 3^{40} \equiv 1 \mod 10^2\)

\(3^{431} = (3^{40})^{10} \times 3^{31} \equiv 3^{31} \mod 10^2\)

\(3^{15} \equiv 7 \mod 10^2\)

\(3^{31} = (3^{15})^2 \times 3 \equiv \underbrace{7^2 \times 3}_{147} \equiv \boxed{47} \mod 10^2\)

What are the last three digits of \(3^{431}\)?

\( \begin{aligned} \phi(10^3) &= \phi(2^3)\phi(5^3) && \text{since } \gcd(2^3, 5^3) = 1 \\ &= \underbrace{(2^3 - 2^2)}_{4} \underbrace{(5^3 - 5^2)}_{100} \\ &= 400 \\ 3^{\phi(10^3)} &= 3^{400} \equiv 1 \mod 10^3 \\ 3^{341} &= 3^{400} \times 3^{31} \equiv 3^{31} \mod 10^3 \\ 3^{10} &\equiv 7^2 \mod 10^3 \\ 3^{31} &= (3^{10})^3 \times 3 \equiv 7^6 \times 3 \mod 10^3 \\ 7^6 &\equiv 649 \mod 10^3 \\ 7^6 \times 3 &\equiv \underbrace{649 \times 3}_{1947} \equiv \boxed{947} \mod 10^3 \end {aligned} \)

What are the last four digits of \(3^{431}\)?

\( \begin{aligned} 3^{431} = 3^{400} \times 3^{31} = (3^4)^{2^2 5^2} \times 3^{31} \equiv a \times b \mod 10^4 = 2^4 \times 5^4 \end {aligned} \)

\( \begin{aligned} 3^4 \equiv 1 \mod 2^4 \\ 3^{400} = (3^4)^{2^2 5^2} \equiv 1 \mod 2^4 \\ 3^{431} \equiv 3^{31} \equiv 11 \mod 2^4 \end {aligned} \)

print(f'{len(str(3**431))}')

print(f'{3**   4%10}')
print(f'{3**  40%100}')
print(f'{3** 400%1000}')
print(f'{3**4000%10000}')

print(f'{3**431%10}')
print(f'{3**431%100}')
print(f'{3**431%1000}')
print(f'{3**431%10000}')
206
1
1
1
1
7
47
947
9947

Divisor Function#

Claim

Let \(d(n)\) be the number of divisors of the integer \(n\) with prime factorization \(p^a q^b r^c \dots\)

Then \(d(n) = (a + 1)(b + 1)(c + 1) \dots\)

How many divisors does a perfect square have? An odd number since the exponents in their prime factorizations are all even.

\( \begin{aligned} 4 &= 2^2 &&& 3 &&& 2^0 \times 2^2, 2^1 \times 2^1 \\ 9 &= 3^2 &&& 3 &&& 3^0 \times 3^2, 3^1 \times 3^1 \\ 16 &= 2^4 &&& 5 &&& 2^0 \times 2^4, 2^1 \times 2^3, 2^2 \times 2^2 \\ 25 &= 5^2 &&& 3 &&& 5^0 \times 5^2, 5^1 \times 5^1 \\ 36 &= 2^2 3^2 &&& 9 &&& 2^0 3^0 \times 2^2 3^2, 2^1 3^0 \times 2^1 3^2, 2^0 3^1 \times 2^2 3^1, 2^2 3^0 \times 2^0 3^2, 2^1 3^1 \times 2^1 3^1 \\ 49 &= 7^2 &&& 3 &&& 7^0 \times 7^2, 7^1 \times 7^1 \\ 64 &= 2^6 &&& 7 &&& 1, 2, 4, 8, 16, 32, 64 \\ 81 &= 3^4 &&& 5 &&& 1, 3, 9, 27, 81 \\ 100 &= 2^2 5^2 &&& 9 &&& 1, 2, 4, 5, 10, 20, 25, 50, 100 \\ 121 &= 11^2 &&& 3 &&& 1, 11, 121 \\ 144 &= 2^4 3^2 &&& 15 &&& 1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 36, 48, 72, 144 \\ 169 &= 13^2 &&& 3 &&& 1, 13, 169 \\ 196 &= 2^2 7^2 &&& 9 &&& \\ 225 &= 3^2 5^2 &&& 9 &&& \\ 256 &= 2^8 &&& 9 &&& \\ 289 &= 17^2 &&& 3 &&& 1, 17, 189 \\ 324 &= 2^2 3^4 &&& 15 &&& \\ 361 &= 19^2 &&& 3 &&& 1, 19, 361 \\ 400 &= 2^4 5^2 &&& 15 &&& \\ 441 &= 3^2 7^2 &&& 9 &&& \\ 484 &= 2^2 11^2 &&& 9 &&& \\ 529 &= 23^2 &&& 3 &&& 1, 23, 529 \\ 576 &= 2^6 3^2 &&& 21 &&& \\ 625 &= 5^4 &&& 5 &&& 1, 5, 25, 125, 625 \\ 676 &= 2^2 13^2 &&& 9 &&& \\ 729 &= 3^6 &&& 7 &&& \\ 784 &= 2^4 7^2 &&& 15 &&& \\ 841 &= 29^2 &&& 3 &&& 1, 29, 841 \\ 900 &= 2^2 3^2 5^2 &&& 27 &&& \\ 961 &= 31^2 &&& 3 &&& 1, 31, 961 \\ 1024 &= 2^{10} &&& 11 &&& \\ \end {aligned} \)




Resources#




Acknowledgements#

SDCP 2006 Dasgupta, Sanjoy; Christos Papadimitriou; & Umesh Vazirani. Algorithms. McGraw-Hill.

KRDM 2018 Rosen, Kenneth. Discrete Mathematics and its Applications 8e. McGraw-Hill.

CENT 2023 [ h ] Vaughan, Robert. A Course of Elementary Number Theory. CMPSC/MATH 467 Factorization and Primality Testing. The Pennsylvania State University. [ book ]