Number theory
This section is currently under construction. Use the search bar to find the topic you are looking for.
Number theory basics
- - divides
- - the set of all integers that are multiples of
Divisibility
The greatest common divisor of two integers and is the largest integer that divides both and :
This can be extended to more than two integers. When , we say that and are coprime.
We also have the following properties:
For any , they are coprime if and only if there exist integers such that:
The least common multiple of two integers and is the smallest integer that is a multiple of both and :
This can be extended to more than two integers. We also have the following properties:
Prime numbers
Every integer greater than 1 can be expressed uniquely as a product of prime numbers.
If is a prime number and is an integer not divisible by , then:
A natural number is a prime number if and only if:
Euler’s totient function
The Euler’s totient function is the number of positive integers less than that are coprime to .
- If is a prime number, then
- If and are coprime, then
- If is a prime number and , then
If and are coprime, then:
Tricks
Recovering a base from two coprime powers with Bézout
If you can obtain two powers and of the same unknown base with coprime exponents (), you can recover itself even without being able to invert the exponentiation (no root, no discrete log needed). Bézout’s identity gives integers such that , hence:
This works in any group (integers mod , matrices, elliptic curve points), and is typical against an oracle that exponentiates a chosen base by a secret (but coprime between calls) exponent. The exponents come from the extended Euclidean algorithm (
xgcdin SageMath).