Prime Number
Check primality, view factor breakdowns, and find neighboring primes.
Number Input
Enter an integer to inspect primality and factors.
About this topic
Primality Test Check if a number has exactly two divisors.
A prime number is a positive integer greater than 1 that cannot be formed by multiplying two smaller positive integers. It has exactly two divisors: 1 and itself.
Key formulas & rules
- •Must be greater than 1
- •Only divisible by 1 and itself
- •2 is the only even prime
- •1 is neither prime nor composite
- •Tested via trial division up to √n
- •There are infinitely many primes
Examples
| Input | Output | Note |
|---|---|---|
| 2 | Prime | Smallest prime |
| 4 | Composite | Divisible by 2 |
| 17 | Prime | No factors up to √17 |
| 1 | Neither | Edge case |
Real-world uses
Prime Factorization Breaking a number down into its prime components.
Every integer greater than 1 can be uniquely represented as a product of prime numbers. This is the Fundamental Theorem of Arithmetic.
Key formulas & rules
- •Every composite number has a unique prime factorization
- •Factors are found by dividing by primes
- •Helps find GCD and LCM
- •Number of divisors can be calculated from exponents
- •Used in simplifying fractions
Examples
| Input | Output | Note |
|---|---|---|
| 12 | 2² × 3 | Prime factors |
| 60 | 2² × 3 × 5 | Prime factors |
| 97 | 97 | Already prime |
| 100 | 2² × 5² | Prime factors |
Real-world uses
Neighboring Primes Finding the closest primes above and below a number.
For any given integer, there is always a prime number larger than it (Euclid's theorem), and a previous prime below it. Finding these neighbors is useful in hashing and prime gap analysis.
Key formulas & rules
- •Always a next prime for any integer
- •Previous prime requires n > 2
- •Gaps between primes vary widely
- •Twin primes differ by 2 (e.g., 11 and 13)
- •Large gaps are called 'prime deserts'
- •Used in dynamic hashing
Examples
| Input | Output | Note |
|---|---|---|
| n = 10 | Prev: 7, Next: 11 | Standard gap |
| n = 24 | Prev: 23, Next: 29 | Gap of 6 |
| n = 89 | Prev: 83, Next: 97 | Gap of 14 |
| n = 2 | Prev: None, Next: 3 | Start of primes |
Real-world uses
Modes & formulas
Primality Check & Factors
A composite number has at least one divisor other than 1 and itself. Checking only up to √n is sufficient — if n = a × b, at least one of a or b must be ≤ √n.