A number is said to be prime if it's only divisors are and symbolically that is
Set of Primes
We denote the set of primes as
If a Prime Divides Another they are Equal
Suppose that , then
Since then we know that or the former is impossible since therefore as needed.
Primes of the Form 4k Plus Something
Suppose that then there exists some such that
By the quotient remainder theorem we have that where and , when the only possibility is that and , on the other hand for any we have that , now if or then the prime is divisible by and which makes not prime, which is a contradiction, therefore .
Increasing Prime Function
We let the function be an increasing function such that and there are no primes between and .
This function looks like
Composite
We say that where is composite if there exists an such that
The composites union the primes is
Composite iff Not Prime
Let then is composite iff is not prime
We know that it's always true that and therefore if is not prime iff it has some other divisor other than or iff is composite
A Prime is Relatively Prime to Anything Else That is Not a Multiple of It
If were to divide , the proof is over so we assume that it does not. thereforeand then , then , so then divides the right hand side, therefore , as needed.
To show existance we will use the well ordering principle so consider the set observe that so therefore and therefore by the well ordering principle it has a least element therefore by the definition of we know that , lets show that is prime.
Let if , then so all is well, on the other hand if so that then since we already knew that and that division is transitive then we know that which means that , since is the minimal element of then at the same time since then we know that , thus since is anti-symmetric, then .
Thus is prime, and as needed.
Every Number is a Product of Primes
For every for some
We prove the statement true via strong induction, for the base case of we see that works, namely that .
Now suppose for some the statement we'd like to prove holds for we'll prove that the statement holds true for , so consider , if it is prime, then we are done, as we can take it as the singleton product, elsewise it is not prime, and therefore it is composite so we get such that by our induction hypothesis we know that the statement holds true for and thus we get and for some , thus so that is the product of primes as needed.
There are Infinitely Many Primes
As per title.
Suppose that there were finitely many primes, and we listed all of them here: for and consider For every we have that therefore , at the same time must be divisible by some prime but clearly for any or else which would be a contradiction, since it's not equal to any of the primes we listed, this is a contradiction because we know that it contained all primes, therefore our assumption is incorrect and there must be infinitely many primes.
There is a Prime Between n and n Factorial
For any there is a prime number such that
Let since then at least so it is non-empty. Since then we know that and therefore there is a prime number which divides it, say it is , for any we know that therefore thus , since then so that
n Minus 1 Factorial is Divisible by n
Let , show that if is not a prime then we have
In the case that then we know that which has remainder 2 upon division by as needed.
On the other hand, whenever we have then since is not prime, then it is composite and therefore there exists such that . If then therefore so that .
On the other hand, supposing that then we see that since then we know that . Actually we know more, since then so we can say that so that so that both appear in the factorials product so that as needed.
There are Gaps of Arbitrary Size between Consecutive Primes
Suppose that is an increasing sequence of all the primes, then for every there exists an such that
Let , consider the following numbers since there are numbers here, and for each element of the form we know that since this makes it composite, and thus not prime, thus take as the greatest index such that thus the gap between and must be at least as needed.
Fundamental Theorem of Algebra
For every can be written uniquely as where all but finitely many
Prime Factors
Let and consider its prime factorization where all but finitely many then we define
Prime Power Sequence
Given any and its prime factorization then we define Note that
Note that since each number has a unique factorization then is a bijection, and so exists.
Products as the Addition of Power Sequences
Suppose that then
Max of the Prime Power Sequence is 0 iff They share no Prime Factors
Let then
Relatively Prime In terms of Prime Factorization
The following are equivalent
Coprime and 5
Suppose that are coprime, then find all possible values of
Let's consider a common divisor of and recall that there exists a such that therefore by transitivity we have and in the latter case, we see that either or or .
The above says that given any prime divisor of then it turns out that prime divisor must be therefore for some . Suppose that , if that's true then we have and from the former so we havetherefore or , without loss of generality if we assume that then in conjunction with we have therefore so that therefore which is a contradiction, therefore it must be that .
Therefore the only possible values of is or therefore the only possible values of is or
Subsequence of the sum of Two Disjoint Power Sequences Is Still a Disjoint Sum
Suppose that and that then where and and
A Number Divides a Coprime Product iff It is the product of Individual Divisors
Suppose that then if and only if where are divisors of respectively
Suppose that therefore and therefore where and where (by the corollary). Therefore but we know that and as needed.
Suppose that , since they are divisors we know that there exist such that and so then therefore as needed.
Euclid
For any then if is prime, we have
If a Prime Divides a Product it Divides at Least One of the Factors
Suppose that and then there exists a such that
Prime Divisors of a Factorial are Bounded by the Argument
For every and such that then
Since then there exists some such that therefore so that
A Divisor of a Product of Primes is a Product of Primes with Smaller Powers
Suppose that dm
GCD and LCM as Prime Powers
Suppose that is a collection of primes such that where , then
Perfect Square iff Every Power in the Prime Factorization is Even
Let then is a perfect square if and only if
Suppose that is a perfect square therefore for some but we know that therefore
We have that therefore is a perfect square.
Division and Prime Power Equivalence
Suppose that then
Every Composite Three Digit Number must have a Prime Factor Less than or Equal to 31
As per title.
Assume that for the sake of contradiction the statement was not true, therefore there is a three digit number such that all of its prime factors are greater than 31, the next prime is and so the smallest three digit number hvaing all prime factors greater than would be which is a four digit number, thus our assumption was false, so that every three digit number must have a prime factor less than or equal to .
Lower Bound on Primes in Factorization Limits the Number of Prime Factors
Let and suppose that for all primes , what can we conclude about the prime factorizatio of ?
Suppose that , we can see that and therefore by the contrapositive of our assumption we have that therefore for if then so we've shown that which is a contradiction so indeed , therefore we conclude that the prime factorization of has at most two different primes in it.
Goldbach Equivalence
Show that every even integer is the sum of two primes if and only if every integer is the sum of three primes
Suppose the former, let such that if is even, then so is and we see and so , otherwise use .
Suppose the latter and let be even, in other words therefore is an even number and we know that therefore , since is even then so is but the sum of three numbers is only even when exactly one is even or all are even, therefore at least one of them is even, but there is only one even prime number, and therefore without loss of generality assume that so we have and therefore as needed.
p Minus one Factorial is Congruent to Minus one Mod p
Suppose that is prime, then
Recall that is a complete set of residues mod , and also for any since then the collection is a complete system of residues mod . Since it is then there is exactly one element such that specifically where so we can say that .
In the previous paragraph we've shown the existance of a function such that . We're going to prove this function is injective, that is we will prove that if then . Suppose that therfore moreover by the definition of we know that therefore we have thus since we know that therefore so that as needed. As a side note since the size of the domain is the same as the size of the range, then we know that is a bijection.
For a moment let's consider the case when if that were true we have therefore if this means that , if then we know that , since then so that but then we deduced that which is a contradiction so that we must have so that . On the other hand if we know that then we see that since then the only possibility is that which is that .
The result of the above paragraph is that if then the only possibility is that or that , so and , and this function is a bijection, remaining a bijection on the restriction of the domain and range to .
For a moment note that if this whole question is trivial because , therefore we can assume that also this implies that is odd, therefore when we consider the collection then since then the size of is even since is odd. Let then , Let , since is a bijection, then by repeating this process times then which is to say that is a partition of , thus But we see and therefore therefore as needed.
The above is usually referred to "Wilsons Theorem".
p Minus two Factorial is Congruent to One Mod p
Suppose that is prime, then
Recall that but at the same time we know that therefore multiplying both sides by we obtain that
This allows us to conclude things like: .
Factorial Fun
Find the remainder when is divided by
We know that and that therefore
1 2 3 n go
Show that for any then iff is prime
Suppose that is prime, therefore we also know that therefore we know that thus as needed.
For the other direction assume that therefore we know that by multiplying both sides by -1, re-writing the factorial and then multiplying by -1 again, we obtain that therefore by wilsons theorem we know that is prime.
Generalized Wilson's Theorem
Suppose that and that then we have
We know that the base case holds. Therefore we move directly to the induction step, where we assume that the statement holds true for , and we have to prove that We have that thus by multiplying both sides by we obtain that as needed.
Wilson Folded in Half
Suppose that is prime, then
Observe that since is odd. Since then we know so that , similarly since then so that , moreover therefore we have:
focusing on the terms that come after in the above product we see that first congruence comes from the fact that , and notice that they are congruent to the negative versions of the terms in the first half of the factorial, and so we can "fold" it in half to get Since there are exactly negative terms we can factor a out from all of them, leaving square of the consecutive numbers so that by wilsons theorem we know that therefore we have since is odd, then is even, therefore , therefore as needed.
Fermats Helper
Suppose is prime, and so that then
Recall that is a complete system or resides mod , and since then so is therefore But we also know that so we conclude that But then
Fermats Helper Mod Exponent
Suppose that is prime, and such that then
By the quotient remainder theorem we know that where therefore where in the 3rd last line we used fermats helper.
Fermats Little
For any which is prime, then for any we have
Suppose then the statement holds true as . On the other hand if then so by multiplying by we have
Remainder of Power Plus One
Find the remainder of modulo
Observe that by fermats helper since we have that since then we see that since then therefore
2's and 5's
Show that is divisible by
Note that in general , therfore note that and that .
We use this to simplify each base mod , we have that
also that therefore we know that We will now look at since we know that then , we will now look at since we know that that then therefore
Prime Power Sum
Suppose that then compute
Since for each we know that by fermats little theorem that thus we have that now since then we know that is an even number therefore we know that therefore we have which shows that
If a Doesn't Divide p Then Fermats Little Theorem and Fermats Little Helper are Equivalent
Suppose that is prime and such that then
Suppose that then multiply both sides by . Suppose that sincethen as needed.
Almost Prime
Show that for any we have
Recall that , what we will is that we will consider the equations , trivially for each equation works, and therefore by the chinese remainder theorem any other solution is congruent to mod 30. Our goal will be to show that also satisfies the equations which will allow us to deduce that
Lets confirm that , we do know that so that as needed. We take a similar approach to mod since we know that then , finally for mod we have as needed.
Therefore we've deduced that is also a solution, and therefore
Carmichael
We say that is carmichael if for every , and is not a prime.
561 is Carmichael
As per title.
Our goal is to show that for any we have , we also have to show that is not a prime, which is true because . Refocusing on the initial goal, we will prove this is true by considering the equations and noting that is a solution, and also showing that is also a solution, and therefore concluding by the chinese remainder theorem.
Note that if then and therefore therefore applying that idea to we see that if any of them divide we immediately obtain .
Otherwise things still work, for if then we know that since is even then so we have . Similarly if then and therefore so that . Finally if then we have and so that .
What we've shown is that no matter what we have that and therefore by our original paragraph we are done.
As it turns out , therefore it is square free and since then it is carmichael
Fermats Compositeness Test
Suppose such that then if then is composite
Observe the contrapositive of fermats little helper which states that from this we conclude that but since then therefore we must conclude that is not prime, and therefore composite.
Fermat Witness
If passes the compositeness test, then is said to be a Fermat Witness for
Pseudoprime to base
Suppose that and that and is not prime, then is called a pseudoprime to base .
Most of the time when you find that , then is prime, that's why the ones that aren't are called pseudoprimes.
is a Pseudoprime to base
As per title.
Firstly we note that is divisible by because and therefore now we'll verify that , note that and since so that thus we know that therefore .
On the other hand , we can see this is true by using the chinese remainder theorem on the equations and and noting that solves it, but also the switch summation also solves it but the switch is not congruent to 3, so it works.
Fermat Primality Test
Let , and define the following function :
if return
let
if return
return
Let . If then is composite, otherwise we say that is a probable prime
Every Carmichael Number is a Probable Prime
Suppose is Carmichael, then using the Fermat Primality Test, it is a probable prime.
Since is Carmichael we know that for any , during the test each has the property that therefore , this means at each stage in the test line 4 is reached until it terminates at line 1 and returning therefore is a probable prime.
At Least Half of the Tested Elements will be Witnesses to a Composite Non-Carmichael Number
Suppose that is composite and not Carmichael and let and , then
To prove this true, we will consider the set , and note that then if we are able to show that then we have and we would deduce that
Since then all elements are incongruent mod , let this can be done because is non-empty as is not carmichael so that there exists an element such that .
Since then the collection of elements are also incongruent mod , since equality implies congruent, then non-congruent implies not equal, and therefore generates a collection of unique elements, so that .
But note, given some we have that therefore we deduce that so then therefore , so that by our introductory paragraph, we've proven what we needed to.
Every Odd Number is a Difference of Squares
For any that is odd there exists such that
Since is odd, then there is some such that , note that is similar to and so that as needed. Note that in this proof and so we are really saying that
The Sum is less than or Equal to the Product
Suppose that then if or then
Suppose that and without loss of generality assume that therefore Now suppose that
Fermats Factorization
Suppose that is odd, then is composite iff there exists such that where
We can't use the fact that every odd number is a difference of squares, this is because the solution to that equation was specifically which is explicitly disallowed for this proposition, therefore instead we note that is composite so there exists such that . But at the same time, we know that We'll now prove that .
Suppose that since then we know also note that therefore and , if were to be prime, then without loss of generality suppose that and therefore so then which is a contradiction, and therefore must be composite.
import math
def fermat_factor(n):
assert n % 2 != 0, "Fermat's factorization method works only for odd integers."
print(f"Starting Fermat's factorization for n = {n}")
# Calculate the ceiling of the square root of n
x = math.ceil(math.sqrt(n))
print(f"Initial x (ceiling of the square root of n): {x}")
if x * x == n:
print(f"{n} is a perfect square. Factors are {x} and {x}.")
return x, x
y2 = x * x - n
print(f"Initial y^2 = {x}^2 - {n} = {y2}")
# Loop will always terminate because (x, y) = ((n + 1) / 2, (n - 1) / 2) is a valid solution
while not last_two_digits_possible_square(y2) or not is_perfect_square(y2):
print(f"y^2 = {y2} is not a perfect square. Incrementing y^2 and then x.")
# Update y^2 incrementally
y2 += 2 * x + 1 # Efficiently calculate the next y2 using (x+1)^2 = x^2 + 2x + 1
x += 1 # Increment x after updating y^2
print(f"New x = {x}, new y^2 = {x}^2 - {n} = {y2}")
y = int(math.isqrt(y2))
print(f"Found perfect square y^2 = {y2}. y = sqrt({y2}) = {y}")
print(f"Factors are (x - y) = {x - y} and (x + y) = {x + y}")
return (x - y, x + y)
def last_two_digits_possible_square(n):
# Set of possible last two digits of a perfect square
possible_last_two_digits = {0, 1, 4, 9, 16, 25, 36, 49, 64, 81,
20, 21, 24, 25, 29, 41, 44, 45, 61, 69, 84}
return (n % 100) in possible_last_two_digits
def is_perfect_square(n):
# Check if the number is a perfect square
root = int(math.isqrt(n))
return root * root == n
# Example usage:
n = 5959
factors = fermat_factor(n)
print(f"The factors of {n} are {factors}")