Verificador de Números Primos
Verifique se qualquer número até 10¹² é primo, veja sua fatoração e explore fatos sobre primos relacionados.
Sobre esta ferramenta
Insira qualquer inteiro até um trilhão e descubra instantaneamente se é primo. Usa o teste de primalidade de Miller-Rabin para números grandes. Mostra a fatoração em primos para números compostos, encontra os primos anterior e próximo, identifica primos especiais (Mersenne, gêmeos, seguros) e pode gerar os primeiros N primos.
Como usar
- 1 Insira um número inteiro positivo no campo de número.
- 2 Clique em Verificar para testar a primalidade e ver a fatoração.
- 3 Use Próximo Primo e Primo Anterior para navegar pela sequência de primos.
- 4 Defina uma quantidade e clique em Gerar Primos para listar os primeiros N primos.
What makes a number prime
A prime number is a whole number greater than 1 whose only divisors are 1 and itself. 7 is prime because nothing between 2 and 6 divides it evenly; 9 is not, because 3 × 3 = 9. Primes are the atoms of arithmetic: every integer above 1 is either prime or a unique product of primes, a result so fundamental it is called the Fundamental Theorem of Arithmetic. That uniqueness is why this tool, when a number is not prime, shows its full prime factorization — the one and only way to break it into prime building blocks.
How the tool tests primality so fast
The obvious way to check a number is trial division — try dividing by every integer up to its square root. That is fine for small numbers but crawls for large ones. This tool instead uses the Miller–Rabin primality test with a fixed set of "witnesses." Miller–Rabin reframes the question: it picks a base a and checks an algebraic identity that every prime must satisfy. If the number fails the identity for any witness, it is definitely composite. If it passes for the right set of witnesses, it is guaranteed prime below a known limit.
Crucially, the implementation uses a deterministic set of witnesses — the small primes 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41 — which are mathematically proven to give a correct answer for every number this tool accepts (up to 10¹²). The arithmetic is done with JavaScript BigInt so that the intermediate squarings never overflow. The result is an exact yes/no, not a probabilistic guess, computed almost instantly even for twelve-digit inputs.
A worked example
Enter 561. It looks like it might be prime — it is odd and not obviously divisible by small numbers. Trial division finds 561 = 3 × 11 × 17, so the tool reports it composite and shows that factorization. (561 is famous as the smallest Carmichael number, a composite that fools the simplest primality tests — but not Miller–Rabin with these witnesses.) Now enter 8191. It passes every witness, so the tool reports PRIME, and because 8191 = 2¹³ − 1 it also flags it as a Mersenne prime.
The special-prime badges
When a number is prime, the tool surfaces some of the structure mathematicians find interesting:
| Badge | Meaning | Example |
|---|---|---|
| Mersenne prime | One less than a power of two, 2ᵏ − 1, where k is itself prime | 31 = 2⁵ − 1 |
| Twin prime | Differs by 2 from another prime | (11, 13) |
| Safe prime | (p − 1)/2 is also prime | 23, since 11 is prime |
These are not trivia for their own sake. Mersenne primes drive the search for the largest known primes; twin primes sit at the heart of a famous unsolved conjecture; and safe primes are deliberately chosen in cryptography because their structure resists certain attacks on Diffie–Hellman key exchange.
Reading the factorization
For composite numbers the tool computes the prime factorization by trial division up to the square root, collecting repeated factors into exponents. So 360 is shown as 360 = 2³ × 3² × 5 rather than the longer 2 × 2 × 2 × 3 × 3 × 5. The exponent form is the compact, canonical way to write a factorization and the form you need for finding divisor counts, greatest common divisors, or least common multiples.
Why primes matter in the real world
- Public-key cryptography. RSA encryption relies on the fact that multiplying two large primes is easy but factoring the product back is, with current methods, infeasible. The security of much of the web rests on that asymmetry.
- Hashing and data structures. Hash tables often use a prime number of buckets to spread keys evenly and avoid clustering.
- Pseudo-random generators. Many random-number algorithms use prime moduli to maximise their cycle length.
- Error-correcting codes. Several coding schemes are built over fields whose size is prime.
Tips and common misconceptions
- 1 is not prime. By definition a prime has exactly two distinct divisors; 1 has only one, so it is excluded. The tool requires inputs of at least 1 and treats 1 as non-prime.
- 2 is the only even prime. Every other even number is divisible by 2, so primality "thins out" to odd candidates above 2.
- Primes never stop. Euclid proved over two thousand years ago that there are infinitely many — the "Generate first N primes" panel just lists them in order, starting from 2.
- Ending in 5 or an even digit means composite. Except for 2 and 5 themselves, any number ending in 0, 2, 4, 5, 6, or 8 is divisible by 2 or 5 and cannot be prime — a quick sanity check before you even type.
Everything runs in your browser; numbers you test are never sent anywhere.
Perguntas frequentes
Calcule porcentagens, aumentos, descontos, gorjetas e percentual do total — seis modos.
Calculadora científica completa com trigonometria, logaritmos, potências e histórico — funciona inteiramente no seu navegador.
Calcule média, mediana, moda, desvio padrão, variância e mais a partir de qualquer conjunto de dados.