Prime Factorization Calculator
Factor an integer into primes and see the canonical form, number of divisors τ(n), sum of divisors σ(n), and Euler’s totient φ(n).
| Prime (p) | Exponent (e) | p^e |
|---|---|---|
| 2 | 3 | 8 |
| 3 | 2 | 9 |
| 5 | 1 | 5 |
- 360 = 23 × 32 × 5
- 9973 (prime) = 9973
- -84 = -1 × 22 × 3 × 7
How the Prime Factorization Calculator Works
The Prime Factorization Calculator decomposes any supported integer into its prime factors and then uses that factorization to compute key arithmetic functions. It clearly displays the canonical prime product (including sign), the number of divisors τ(n), the sum of divisors σ(n), and Euler’s totient φ(n) for |n|, with explicit handling of 0, ±1, and negative numbers. It is designed as both a practical tool and a clean number theory reference.
Supported Inputs & Validation
To keep results exact and safe in JavaScript, the calculator:
- Accepts a single signed integer n with |n| ≤ 9,007,199,254,740,991 (2⁵³ − 1).
- Requires input to match an integer pattern (optional leading minus).
- Validates with schema-based checks; invalid or out-of-range inputs show a clear error instead of incorrect math.
A dedicated Calculate action runs the factorization, while Clear resets the form so you can quickly try another integer.
Special Cases: 0, 1, and Negative Numbers
- n = 0: The tool explains that 0 has infinitely many divisors and cannot be expressed as a finite prime product, so no standard factorization is shown.
- n = 1 or -1:
- Shows the canonical form (1 or -1 × 1).
- Notes that there are no prime factors for |n| = 1.
- Reports τ(1) = 1, σ(1) = 1, and φ(1) = 1 by convention.
- Negative integers: Factors are computed on |n| and the canonical form is written as -1 × (prime factors of |n|). Divisor functions τ(n), σ(n), and φ(n) are reported for |n|.
Trial Division with 6k ± 1 Optimization
For general |n| ≥ 2, the calculator uses an optimized trial division algorithm:
- First removes all factors of 2 and 3.
- Then tests potential factors of the form 6k ± 1 up to √|n|.
- For each prime factor p found, counts its exponent e and records (p, e).
- If the remaining value after division is greater than 1, it is prime and added as p¹.
This approach is fast and reliable for integers within the safe range, making it ideal for homework, teaching, and contest-style problems without heavy cryptographic algorithms.
Canonical Form, τ(n), σ(n) & φ(n)
Once n is factored as n = p₁^(e₁) × p₂^(e₂) × … × pₖ^(eₖ), the calculator derives:
- Canonical prime product: a clean string like-1 × 2³ × 3² × 5 for negative numbers or just the prime powers for positive n.
- Prime factor table: each prime p, exponent e, and p^e in a structured table.
- Number of divisors τ(n): τ(n) = Π(eᵢ + 1).
- Sum of divisors σ(n): σ(n) = Π((pᵢ^(eᵢ+1) − 1) / (pᵢ − 1)).
- Euler’s totient φ(n): for |n| ≥ 2, φ(n) = n × Π(1 − 1/pᵢ) using distinct primes.
All integer outputs are formatted with thousands separators for readability, which is especially helpful when exploring large composite numbers.
Scope & Educational Insight
This Prime Factorization Calculator is designed for:
- Students learning prime factorization, divisors, and multiplicative functions.
- Teachers demonstrating how τ(n), σ(n), and φ(n) all follow directly from the prime factorization.
- Quick checks on competition-style problems and integer properties.
It intentionally does not attempt large-integer or cryptographic factoring. Instead, it focuses on being a clear, exact, and trustworthy reference for the full structure of typical integers—making number theory more intuitive and accessible.