What This Calculator Does
- ✅ Prime Check: Determines if a number is prime, composite, or neither — with a clear explanation.
- ✅ Prime Factorization: Breaks composite numbers into prime factors with step-by-step division.
- ✅ Prime Position: Shows which prime number your input is (e.g., 97 is the 25th prime).
- ✅ Neighboring Primes: Finds the previous and next prime, with prime gaps.
- ✅ Twin Prime Detection: Checks if your number is part of a twin-prime pair.
- ✅ Nth Prime: Finds the prime at any position in the sequence (e.g., the 100th prime is 541).
- ✅ Prime Range: Generates all primes in a given interval or the first N primes.
- ✅ Prime Count: Counts primes in a range without generating the full list.
Supports large integers beyond JavaScript's safe limit. Factorization of very large composites may require additional computation time.
Formulas & Rules
- Primality Test: n is prime if no integer d where 2 ≤ d ≤ √n divides n evenly.
- Prime Factorization: Every integer n > 1 can be written uniquely as a product of prime powers: n = p₁^a₁ × p₂^a₂ × ... × pₖ^aₖ.
- Divisor Count: If n = p₁^a₁ × p₂^a₂ × ... × pₖ^aₖ, then d(n) = (a₁+1)(a₂+1)...(aₖ+1).
- Divisor Sum: σ(n) = ∏ [(pᵢ^(aᵢ+1) − 1) / (pᵢ − 1)]
- Twin Primes: (p, p+2) where both p and p+2 are prime.
Examples
- Prime Check: 97 → Prime. Position: 25th. Previous: 89 (gap 8). Next: 101 (gap 4).
- Composite: 91 → Composite. 91 = 7 × 13. Smallest prime factor: 7.
- Factorization: 360 = 2³ × 3² × 5. Total prime factors: 6. Unique: 3. Sum: 10.
- Nth Prime: The 100th prime is 541.
- Range: Primes between 1 and 100 → 25 primes (2, 3, 5, 7, ..., 97).
- Twin Prime: 29 and 31 are twin primes.