Prime Factorization Calculator
Discover the fundamental theorem of arithmetics with our prime factorization calculator. This tool will explain thoroughly how to calculate the prime factors of any number. Here you will learn:
- What is the factorization of a number, and the prime factorization;
- What are prime numbers;
- Why does is not a prime number?
- How to calculate the prime factors of a number?
- A simple example: the prime factorization of 20;
- The prime tree number calculator: a visual representation of the prime number factorization.
We also have other handy tools that may be very convenient for solving some math problems you encounter. Give it a try and check our determinant solver or polynomial grapher!
What is factorization? And what is prime factorization?
In mathematics, the factors are the operators in a multiplication: in , and are the factors.
Writing a number as the result of the multiplication of a series of factors is called factorization. When decimal numbers are allowed, factorization is trivial, but when we restrict to integers and maintain that only multiplication is allowed, we are on an entirely different ground.
The integer factorization of a number is a bit of an "inverse" multiplication, where we find the factors from the product. Here's an example:
Looks easy? Think again! 😁 We can lay down some rules to find the factors, but the result may not be univocal:
And so on. This is where we can remove a bit of this uncertainty: let's restrict the possible factors to prime numbers and their powers only. If we do so, we obtain what we call prime factorization of a number. In the case of , the prime factorization is:
Don't worry; we will spend some time on this!
What's a prime number? A primer
Prime numbers are the MVPs of maths. Endlessly mysterious, we all know them by their definition, numbers that are divisible only by and by themselves. We love them and think — we are pretty sure of this — that they are not like the other numbers. We sent them into space, trying to signal our supposed intelligence. We base our banking on them. We made gigantic leaps in understanding them, but there are gaping holes in our knowledge: take a look at the Wikipedia page for unsolved mathematical problems, .
Here are the first prime numbers:
And here's the last known by humanity (in May 2022: it will change soon):
A number with digits (we would need half of the Encyclopedia Britannica to write it down). We could use, e.g., the random number generator and check if the number is prime, but that is impossible for a simple computer, unfortunately.
What is prime factorization — in detail
The research of the prime factors of a number is a cornerstone of mathematics. Since Eucildes, the Greek mathematician, we know (with proof!) the fundamental theorem of arithmetics, which states that every positive integer greater than can be factorized in a set of prime numbers and their powers and that this factorization is unique.
This uniqueness of the prime factorization is the reason for which one is not a prime number, even though it technically satisfies all the conditions. If was prime, we would have an infinite number of "different" factorizations: , but also , and so on. Keep that one out of your factors!
An example: the prime factorization of 20
Take a simple number, . We are going to calculate the prime factorization "freehand".
- First step: take that out!
- Hey, do it again!Until the number is even, we can factor out as many twos as possible.
- That's it: is a prime number: .
How to calculate the prime factors of a number?
There are several possible ways to calculate the prime factorization of a number. The most commonly used employs trial division to calculate the prime number tree.
This algorithm is by no means efficient, and in the worst case, it can be extremely lengthy and resource-hungry. There are better alternatives out there, but conceptually we will stick to this one: you will understand how to calculate the prime decomposition in a second without focusing on more abstract and complex math.
How to calculate factorization in prime numbers, then? First, choose the number, then:
- Start dividing it by : if the number is even, you will find your first prime factor. Consider the result of the division as the new number. If the original number is not divisible by , move on.
- If the result is even, go back directly to the beginning: you can divide again by .
- You finally ended up in an odd number: try the next prime number, : is it a divisor?
- Yes! Perfect. Check the result. Is it even? Go back to the beginning. Is it odd? Try again with .
- No. 😔 No worries, move on to the next step!
- Try the division by . We skipped , of course, since it would automatically be considered by two divisions by . Repeat the same steps we followed for .
- Go on! Repeat the steps till the result of the division is .
This is when things get lengthy. Take the number . It's even, good!
- .
- Let's try : nothing;
- Let's try : nothing;
- Let's try : nothing...
In a while, you would finally reach . Yes: it's a prime number! Luckily, there's a workaround: you don't have to try numbers bigger than . Bigger than that, and you would have met the ""other" factor of the multiplication already: if , we reach a "midpoint" at $n=\sqrt{n}\times\sqrt{n}$$, with a "symmetric" progression.
How to use our prime factorization calculator: the prime number tree visualization.
Our prime factorization calculator will show you the prime number tree and calculate the prime decomposition (both in an expanded and short form).
The tree is not necessarily the one we found by dividing the number by increasingly big prime numbers, even though the result will be the same: look at the factors. Only the "intermediate factors" may change during the decomposition.
The problem of prime factorization
Calculating the prime factors of a number is a rather complex problem: in particular, the number of operations required to find the factors increases in a non-polynomial way. The time and resources needed to do so are then higher than, let's say, calculating the square root: the known algorithm are just not good enough.