Prime factorization calculator
Breaks a whole number into prime powers: 360 is 2³ × 3² × 5, with each prime shown next to its exponent. You also see how many distinct primes there are, how many in total, and whether the number is itself prime. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Positive integer to factor
- 360
- Omega
- 3
- Big omega
- 6
Every whole number greater than one factors uniquely into primes raised to powers — the fundamental theorem of arithmetic. This prime factorization calculator takes a positive integer, peels it into those prime powers with a deterministic BigInt algorithm, and returns each base together with its exponent so you can audit RSA-sized classroom examples, check homework, or feed structured factors into another pipeline without hand-written trial loops.
What prime factorization actually returns
Prime factorization rewrites an integer n as a product of primes raised to positive exponents, for example 360 = 2³ × 3² × 5. Uniqueness up to order is guaranteed by the fundamental theorem of arithmetic, so two correct factorizations of the same n always agree once primes are sorted.
This calculator does not stop at a flat list of prime factors with multiplicity; it groups them into prime powers and reports each base with its exponent, which is the form number-theory formulas, radical functions, and Euler totient calculations usually need.
How to call the calculator and read the result
Submit a single field n — a safe JavaScript integer or a plain decimal string without commas, spaces, or scientific notation. Internally the engine promotes n to BigInt, strips factors of two and three, then walks a 6k±1 wheel of candidate divisors up to the square root of whatever remains. When the loop finishes, any leftover greater than one is itself a prime and is appended as a final prime power.
The factors array is ordered by ascending base, exponents are ordinary integers, and bases are decimal strings so callers can round-trip very large primes without precision loss.
What you can do with it
Homework and contest verification
Check student or contest solutions by comparing returned prime powers against hand-worked factorizations for composites and primes alike.
FAQ
Is the prime factorization calculator free?
The browser tool runs free on your device.
Why must n be at least 2?
Prime factorization is defined for integers greater than 1.
Can I factor numbers larger than JavaScript's safe integer range?
Yes. Pass n as a decimal string; the engine uses BigInt up to the published digit limit so large classroom examples stay exact.
How many prime factors does 360 have?
It has 3 distinct primes, 2, 3 and 5, and 6 prime factors in total when repeats are counted, because 2 appears three times and 3 twice. Both counts are shown with the result.
How can I tell whether my number is prime?
The result says so directly. A prime number has only one entry, the number itself with exponent 1, and is marked as prime; any other number shows two or more prime factors.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/numth/prime-factorization \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":"360"}'const res = await fetch("https://api.kit.forhosting.com/numth/prime-factorization", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"n": "360"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/numth/prime-factorization",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"n": "360"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/numth/prime-factorization", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"n":"360"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"n":"360"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/numth/prime-factorization", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"n": "360"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "numth.prime_factorization",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_digits | 18 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Results stay exact as decimal strings, never float-rounded, and the free browser path matches the API byte for byte.
What prime factorization actually returns
The response also carries omega (the count of distinct prime bases) and big_omega (the total number of prime factors counting multiplicity), plus an is_prime flag that is true exactly when n itself is prime. Large values travel as decimal strings so nothing is rounded by IEEE floating point, and the same contract runs free in the browser and through the paid API path at $0.002 per successful request.
How to call the calculator and read the result
Values must be integers at least 2; one, zero, negatives, and fractions are rejected with invalid_input and are never charged. Alias field names number and value are accepted for convenience. Stay within the published digit limit; beyond that bound the request fails fast rather than burning CPU on an intractable trial-division search.
Where structured prime powers are useful
Feed the structured factors into Euler totient, radical, or abundance checks; verify that a challenge modulus is a product of the primes you expect; or document the prime signature of hash-table sizes and random seeds. Failed validation never consumes balance; only successful factorizations bill the published $0.002. Use the browser tool for interactive exploration and the API when a backend, notebook, or batch job must factor many integers under a single prepaid KIT balance without a subscription.
Integration use cases
Cryptography classroom demos
Factor small RSA-style products and show bases plus exponents as structured JSON instead of a single opaque string.
Pipeline number-theory helpers
Emit omega, big_omega, and prime powers for totient, radical, or abundance calculations in automated math pipelines.
Technical questions
How do I factor an integer into primes with this API?
POST an object with field n set to an integer ≥ 2 (or a decimal string). The response lists factors as { base, exponent } pairs plus omega, big_omega, and is_prime.
Is the result deterministic across browser and API?
Yes. The same pure trial-division routine powers both paths, so identical inputs produce identical JSON with no network or randomness involved.