Primality#
Table of Contents#
Programming Environment#
import math
from numba import jit, njit, prange
import numpy as np
from typing import Iterator
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[1], line 2
1 import math
----> 2 from numba import jit, njit, prange
3 import numpy as np
4 from typing import Iterator
ModuleNotFoundError: No module named 'numba'
Questions
Given a composite integer, how do we find a decomposition into a product of integers larger than 1?
How do we recognize a prime integer?
Euclid’s Lemma#
If a prime divides the product of two integers then it must divide at least one of those integers.
Note that the following cases hold as a consequence.
If a prime
divides , then it must divide .
Therefore, if
divides , then divides .
The following theorem is a property which is characteristic of primes and is sometimes used to define them.
Let
be a prime and let and be integers s.t. divides .
divides either or .
The only positive divisors of
are and since is prime.
Then eitheror . If
then . [Humphreys & Prest 1.1.6]
If
then and are relatively prime.
Then there are integersand s.t. .
Sincedivides and divides , divides their sum .
if a prime divides a product then it divides one or the other factor.
The following lemma is an extension of the previous theorem.
Let
be prime and let divide the product .
Thendivides at least one of .
Base Case
If
then . Induction Step
Induction Hypothesis: Let
so that divides at least one of .
Letdivide the product which we want to write as a product of integers.
Definefor and let be the product .
Thenis a product of integers.
Eitherdivides one of or divides .
If the latter, then eitherdivides or divides . Therefore
divides one of .
Prime Factorization#
The decomposition of a positive integer into primes is called its factorization, which is expressed by
where
Relative Primality#
or coprimality
If integers
and have no common primes in their respective factorizations then and are said to be relatively prime.
and are relatively prime.
Let
and be positive integers.
Ifthen and are said to be relatively prime.
Let
, , and be positive integers with and relatively prime.
Then
if
divides then divides
if
divides and divides then divides
Since
and are relatively prime there are integers and st by Bézout’s identity.
. Let
.
Sinceand it is the case that .
. Let
Then there is an integersuch that .
Let
Then there is an integersuch that .
.
. Alternatively
Let
.
.
Let.
.
.
and are relatively prime iff and are relatively prime.
Let
implies that whenever and vice versa.
Pythagorean Triples#
[DEFINITION - (fundamental) Pythagorean triples]
Three integers
Because of the symmetry in
[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
is a fundamental triple.
Furthermore, every fundamental triple is of this form.
Note that the first and third terms are odd and the second term is even.
First few fundamental triples
1
That
Let
Then
2
That a triple is fundamental iff it has the form
Let
Assume
Therefore, either
Since
Since
Thus the factorization will only have even exponents which is another way of saying that
Since
The Fundamental Theorem of Arithmetic#
or the Unique Factorization Theorem for Integers
Factorization into primes is unique up to order.
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.
This does not hold for the extended integers (of the form
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
be an integer with non-unique (but distinct) factorization where the primes are not necessarily distinct, but where the second factorization is not simply a reordering of the first.
The primedivides and so it divides the product of the s.
Since the factorizations of
Therefore
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
Every positive integer
greater than or equal to may be written in the form where the integers are prime numbers (which need not be distinct) and . This factorization is unique in the sense that if also where are primes, then and we can renumber the so that for . 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
Show by strong induction that every positive integer greater than or equal to
Base Case
is prime. For
either is prime in which case has a factorization (with just one factor) of the required form or can be written as a product where and . Induction Step
Induction Hypothesis: Let
and both have factorizations into primes.
We obtain a factorization ofas a product of primes by juxtaposing the factorizations of and . Therefore every positive integer greater than or equal to
has a factorization as a product of primes.