소수 판별기
10¹²까지의 임의의 숫자가 소수인지 확인하고, 인수분해를 보고, 관련 소수 정보를 탐색하세요.
이 도구에 대해
10¹²(1조)까지의 임의의 정수를 입력하면 소수인지 즉시 알 수 있습니다. 큰 수에는 밀러-라빈 소수 판별 테스트를 사용합니다. 합성수의 소인수분해를 보여주고, 다음 및 이전 소수를 찾고, 특수 소수(메르센, 쌍둥이, 안전)를 식별하며, 처음 N개의 소수를 생성할 수 있습니다.
사용 방법
- 1 숫자 필드에 양의 정수를 입력하세요.
- 2 '확인'을 클릭하여 소수 여부를 테스트하고 인수분해를 보세요.
- 3 '다음 소수' 및 '이전 소수'를 사용하여 소수 수열을 탐색하세요.
- 4 개수를 설정하고 '소수 생성'을 클릭하여 처음 N개의 소수를 나열하세요.
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.