Home › Math › Prime Factorization Calculator
Prime Factorization Calculator
Decomposes an integer into its prime factors by trial division, tests primality, and derives the number and sum of its divisors from the exponents.
When to use
You need the prime factors of an integer up to 10^12, want to know whether it is prime, or need its divisor count.
Do not use when: You need the GCD or LCM of several numbers (use gcd-lcm) or factorials and binomial coefficients (use factorial, combinations-permutations).
Formula
n = p₁^k₁ × p₂^k₂ × … (trial division by 2, then odd numbers up to √n); τ(n) = Π (kᵢ + 1); σ(n) = Π (pᵢ^(kᵢ+1) − 1) / (pᵢ − 1)
Inputs
| Parameter | Type | Unit | Required | Description |
|---|---|---|---|---|
n | integer | yes | Integer to factor, from 2 to 1,000,000,000,000. Range: ≥ 2, ≤ 1000000000000 |
Outputs
| Output | Type | Unit | Description |
|---|---|---|---|
is_prime | boolean | true when n has no divisors other than 1 and itself. | |
factors | number_list | Prime factors in ascending order with repetition, e.g. [2, 2, 2, 3, 3, 5]. | |
factorization | string | Prime-power form, e.g. '2^3 × 3^2 × 5'. | |
distinct_primes | number_list | Each prime factor once. | |
divisor_count | integer | τ(n) = Π (kᵢ + 1) over the exponents kᵢ of the factorization. | |
sum_of_divisors | integer | σ(n) = Π (1 + pᵢ + pᵢ² + … + pᵢ^kᵢ), including 1 and n. |
Example
360: {"n":360} → {"is_prime":false,"factors":[2,2,2,3,3,5],"factorization":"2^3 × 3^2 × 5","distinct_primes":[2,3,5],"divisor_count":24,"sum_of_divisors":1170}
97: {"n":97} → {"is_prime":true,"factors":[97],"factorization":"97","divisor_count":2,"sum_of_divisors":98}
GET https://tttkmbb.com/api/v1/calculate/prime-factorization?n=360
Machine access
- API:
GET https://tttkmbb.com/api/v1/calculate/prime-factorization(query parameters) orPOSTwith a JSON body{"inputs": {...}} - Schema: https://tttkmbb.com/api/v1/calculators/prime-factorization · Markdown: https://tttkmbb.com/math/prime-factorization.md · JSON definition: https://tttkmbb.com/math/prime-factorization.json
- MCP: server
https://tttkmbb.com/mcp, toolrun_calculator with calculator_id="prime-factorization" - OpenAPI operationId:
calculate_prime_factorization - Freshness:
static. Authentication: none. Rate limit: fair use (see rate limits).
Sources
- Wikipedia – Integer factorization (reference)
- Wikipedia – Divisor function (reference)
- Wolfram MathWorld – Prime Factorization (reference)
FAQ
Why is 1 not accepted?
1 is neither prime nor composite and has an empty factorization, so the input must be at least 2.
How fast is this for large numbers?
Trial division needs at most about 500,000 divisions for n near 10^12, which takes a few milliseconds; larger inputs are rejected.
Related calculators
- GCD and LCM Calculator — Common factors and multiples of several integers.
- Modulo Calculator — Remainders used in divisibility tests.
- Factorial Calculator — Products of consecutive integers.