NUMBER THEORY:
Number theory is the part of mathematics which studies the integers and their properties (divisibility, prime numbers, representation in different bases)
DIVISIBILITY:
Let and be integers with . We can say that a divides b (written as ) if there exists an integer such that: .
We can then also say that is a multiple of and that is a factor of
so, yea here a would be the denominator in this notation.
Properties of divisibility:
Let be integers with
- , this is basic math.. if you ever get confused write a as the denominator and b and c as the numerator
- for any integers
- for whatever is
- but with 0 excluded
- , where (antisymmetric)
- (transitivity)
so, you can say something like since
Some proofs if you want to know how we established 2, 5, and 6:
Example:
Find all integer such that:
INTEGER DIVISION:
For any integer (the dividend, or numerator) and (the divisor, or denominator), there are two uniquely determined integers (the quotient) and (the remainder) with , such that
- for example, if and , we have , where the quotient is 5 and the remainder is 5
To be clear about integer division vs. real division, we introduce the following notation for integer division:
- (the modulo operation)
For example:
which is real division
- so, floor division would be: (remove the decimal)
- modulo operation would be:
CONGRUENCE:
Let be an integer. Remember that, for two integers and , means that and have the same remainder in the integer division by , that is,
- in simpler terms, we say two numbers are congruent if they leave the same remainder when you divide them by another number. So, if we said is basically saying when you divide 17 by 6 and when you divide 5 by 6 you get the same remainder (5)
The relation is an equivalence relation on the integers
- meaning, it will be reflexive, symmetric, and transitive
- is obviously reflexive
- If then obviously , so it symmetric
- If then . so it is transitive
It is important to know that even if your remainder is negative and one is positive, but they have the same base number, they are still congruent
THEOREM:
iff iff there is an integer such that
- this is basically just different ways of understanding congruence…
Example:
Take and
- checking congruence: because both 17 and 5 leave a remainder of 5 when divided by 6
- using divisibility: which is true, 6 does divide 12 (you get the value 2)
- equation form: , where
PROPERTIES OF CONGRUENCE:
Let be integers and let be a positive integer
- Congruence mod m is an equivalence relation on integers
- meaning, it is reflexive, transitive, and symmetric
- Compatibility with operations: If and
some basic proofs… idk if we should know them but he has them written so
Example:
Find the remainder of divided by 15
^ its important to note that after you reach a remainder of 1, you don't have to write anything after that. I did it so I can show you the cycle continues
also.. you can do something like this:
you establish that 505 x 4 = 2020, its missing a 3 so you do 2^2020 . 2^3, so whatever the remainder of 2^3 mod 15 is is the answer.
PRIME NUMBERS:
A prime number is a positive integer greater than 1 whose only factors are 1 and itself
- like 2, 3, 7, so on
Every integer greater than 1 can be written uniquely as a prime or as the product of two or more primes, where the prime factors are written in order of nondecreasing size
- so, for example: 100 = 2 x 2 x 5 x 5 → 100 =
How do we check if a number is prime?
- If a number is prime, we basically should test the divisibility by all integers from up to
So, if we wanted to check if is prime, we need to see if (we only care about the 5), so we check the divisibility up till 5
- Is it divisible by 2?
- , not an integer
- Is it divisible by 3?
- which is not an integer
- Is it divisible by 4?
- not an integer
- Is it divisible by 5?
- not an integer
Since 29 is not divisible by any integer from 2 → 5, therefore, it has no divisors other than 1 and itself
So, it is a prime number
Theorem: Let be an integer, if is not prime, then has a factor less than or equal to
Proof:
Let where (since N is not a prime number)
On the contrary, assume that and , if we multiply these two, we get:
- which.. not true.
- Therefore, or
EUCLID’S THEOREM:
How many prime numbers? There are infinitely many prime numbers (is what this guy is saying)
How can we prove that this is true? PROOF BY CONTRADICTION.. YAY…
So, let us assume the opposite, let us assume there are finite number of primes
Let us write this as:
Now let us consider a number (multiply all primes then add a one to it)
This means that CANNOT be prime, because
This means, should have a prime factor in order to factor it out of the prime numbers (meaning it does have something you can divide it by)
Let us call this prime factor
So, naturally, is going to be one of the prime numbers →
Therefore, since is a factor of and of course is a factor of the set of prime numbers, this must mean that is a factor of
But, if we look at the previous formula we established, we can see that
Here is where we have the contradiction:
And we know that should be a factor of the number on the left hand side, we can divide it by , which also means we can divide the right hand side by as well
Since is a factor of the number on the left hand side, we should get an integer.
However, you do NOT get an integer on the right hand side. Why?
- is a prime number, and the smallest prime number we have is 2. so 1/ by anything that isn’t one is not going to be an integer. So how can we say …? clearly a contradiction
Therefore, there are infinitely many prime numbers!
FINDING PRIMES:
SIEVE OF ERATOSTHENES:
To find all primes :
- List all natural numbers from to
- Remove all the multiples of the first number in the list (2), except itself
- Move to the next number still in the list (3) and remove all its multiples except for itself
- Move to the next number still in the list (5, since 4 has been removed) and remove all its multiplies except itself
- Keep moving to the next number still in the list and removing all its multiples except itself, stopping when that number is
- The remaining numbers are all and only primes from 2 to
Example:
Find all primes up to 30:
You want to know the time complexity of this algo is… cause don't forget this IS a cs course which is crazy crazy
However, while this might be helpful for smaller numbers… the biggest prime number found is by some computer volunteered by Patrick Laroche of the Great Internet Mersenne Prime Search (GIMPS). So imagine if you used that algo above to find the prime numbers between 2 and whatever the fart that number is… yea good luck bro see you in 100 years
MERSENNE PRIMES:
Prime numbers in the form is called a Mersenne prime.
If is prime, = may or may not be prime
- if (which is prime) → which is prime
- if (which is prime) → which is not prime
If is NOT prime, then surely is not prime either
- if (which is not prime) → which is not prime
GREATEST COMMON DIVISOR (GCD):
For integers and (not zero), the greatest common divisor, denoted as gcd(a,b) is the LARGEST integer such that and
- Integers and are relatively prime, or coprime, if
- A set of integers is pairwise coprime if every pair in the set has a gcd of 1
- Say you have the set , every pair in this set is going to have a gcd of 1
- Therefore, this set is pairwise coprime because every pair has a gcd of 1
Well how can we compute gcd? The gcd can be computed using prime factorizations by taking the minimum exponents for each prime
Example:
Find
A more difficult one:
Find
Finding the gcd through factorization is not an efficient method, cause sometimes the numbers are just way too big
EUCLIDEAN ALGORITHM:
- Divide by , get remainder , a MUST be ≥ b, if it isn’t immediately swap them
- Replace with , with , and repeat until the remainder is 0
- The last non-zero remainder is the gcd
Example:
Find the
Find the
BÉZOUT’S THEOREM:
For integers , there exists integers such that:
Example:
Find the
Now, his examples are literally one sentence and make no sense so I am going to explain it a bit longer but it’ll make sense!
LEAST COMMON MULTIPLE:
The smallest positive integer divisible by both and . So basically
For integers and (not zero), the least common multiple, denoted as is the SMALLEST integer such that and
There is a theorem you can use to get the lcm
This is because there is a theorem that states:
Let and be positive integers. Then:
How can we prove this?:
(i ask prof let us even pray he answers bro)
LINEAR CONGRUENCES:
A congruence of the form , where and are integers, is a positive integer, and is a variable, called a linear congruence.
The solutions of a linear congruence are all integers that satisfy the congruence IF AND ONLY IF divides
How to solve linear congruence?
-
Check if a solution exists (by finding the gcd of a and m and seeing if it divides b)
- If , then there is only one unique solution modulo m
- If :
- If , then no solution exists
- If , then there are distinct solutions modulo m
-
Simplify the congruence
- If AND , divide the entire congruence by
- , which gives us a new congruence such that
- If AND , divide the entire congruence by
-
Find the modular inverse (this only exists IF )
- If , the congruence can be solved by multiplying both sides by the modular inverse of , denoted by
- The modular inverse is an integer such that:
- How do we find the inverse? Using the extended Euclidean Algorithm (you use the coefficient, this will make sense with an example)
Multiply both sides by the inverse
- Once the inverse has been found, multiply both sides of the original congruence
General solution
- If , the unique solution is:
- If and , there are solutions
It is important to note that if you have something like , you can rewrite this as an equation:
Examples:
Solve
Solve
What if we were given the inverse of a number and we had to get its original form?
Consider the following:
in
An inverse of a modulo m exists IFF
CHINESE REMAINDER THEOREM:
Let be two coprime integers. For every , there exists such that the system:
is equivalent to the single congruence . Moreover, if a Bézout identity is known, can be determined as
Example for this nonsense!
Solve for :
Find the common solutions of the 2 congruences and