Prime factorization
Break any whole number from 2 upward into its primes: 360 is 2³ · 3² · 5, or 2, 2, 2, 3, 3 and 5 listed one by one. Both forms appear together, ready to check homework or multiply back. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Integer to factor
- 360
- Factors
- 2, 2, 2, 3, 3, 5
Prime factorization rewrites a whole number as a product of prime powers. Given any integer n greater than or equal to two, this capability returns each prime with its exponent and a flat list of prime factors in ascending order. The result is deterministic trial division with no network calls, no randomness, and no model inference. Use it for homework checks, crypto-related teaching demos, coding interviews, or pipelines that need a machine-readable factorization without installing a CAS.
What prime factorization returns and why both forms matter
Every integer greater than one has a unique multiset of prime factors, up to ordering—this is the fundamental theorem of arithmetic. Compact form groups repeated primes into exponent pairs, so 360 becomes 2^3 · 3^2 · 5^1 rather than a long product. Flat form expands the same factorization into an ordered list such as [2, 2, 2, 3, 3, 5], which is convenient when you need to multiply factors back, feed a sieve step, or display each prime separately in a UI.
This capability returns both views in one response: factorization is an array of objects with integer fields prime and exp, and factors is the expanded ascending list. The original n is echoed so callers can assert round-trip equality by multiplying primes raised to their exponents. Nothing is left to locale, floating-point formatting, or server-side clocks; only integer arithmetic is used until factorization completes.
Practical uses in education, engineering, and automation
Teachers and students use prime factorization to check homework, illustrate unique factorization, and compare hand results against a machine oracle. Data teams sometimes need radical or omega(n) style metrics—counting distinct primes or total prime multiplicity—which fall out of the returned arrays without reimplementing factorization. Security and CTF training labs show how small n factor instantly while large semi-primes do not, reinforcing why RSA moduli must be huge; this tool is intentionally limited to safe integers so it teaches the concept without pretending to be a full integer-factorization service.
What you can do with it
Homework and tutoring checks
Students submit n and compare the returned primes and exponents with their hand-written factorization before turning work in.
Automated grading and coding interviews
Judges multiply p^e from the response and assert equality with n, catching off-by-one exponents without floating-point noise.
Number-theory teaching demos
Show unique factorization live: pick composites, primes, and prime powers, then display both compact and flat forms side by side.
FAQ
What is the prime factorization of a number?
It is the unique product of prime powers that multiplies back to that integer. For example, 12 = 2^2 · 3, returned here as factorization pairs and the flat list [2, 2, 3].
What inputs does this calculator accept?
Only whole numbers n greater than or equal to 2, within the JavaScript safe integer range.
What is the difference between factorization and factors?
factorization groups each prime with its exponent ({prime, exp}). factors expands those powers into a sorted multiset of prime integers.
Does the tool factor cryptographic moduli?
No. It uses trial division on safe integers and refuses oversized n. It is for education, tooling, and ordinary integers—not RSA-scale moduli.
What do I get if the number is already prime?
You get the number itself with an exponent of one, because a prime has no other factors. The list form then holds a single entry, which is a quick way to confirm that a number is prime.
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/math/prime-factorization \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":360}'const res = await fetch("https://api.kit.forhosting.com/math/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/math/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/math/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/math/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": "math.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.
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
API pricing is a flat $0.002 per successful request; invalid inputs are rejected without charge.
How to call it and which inputs are accepted
The value must be a finite whole number greater than or equal to two. There is no optional mode flag: the output always includes both the compact factorization and the flat factors list. Trial division factors out two, then walks odd candidates up to the square root of the remaining cofactor, so composite numbers with small prime factors finish quickly and prime n simply returns a single pair with exponent one. Send a JSON object with a single required field n. Integers may arrive as JSON numbers or as digit-only strings that parse to the same whole value; booleans, arrays, objects, fractions, NaN, Infinity, and values below two are rejected with invalid_input and a clear message. Numbers larger than the JavaScript maximum safe integer are refused so results stay exact in IEEE floating-point doubles used by the worker. For classroom or API demos, start with medium composites such as 360, 1001, or 9876543210-style safe integers rather than cryptographic-size moduli, which this tier-A parse path is not designed to attack. Failed validation never consumes prepaid balance; only successful factorizations bill the published base of $0.002.
Practical uses in education, engineering, and automation
Software engineers embed the call in grading scripts, coding-challenge judges, and property tests that assert product of p^e equals n. Because the browser and API share the same pure function, you can prototype in the free web UI and promote the identical contract to production workers.
Technical questions
How much does the API cost?
Successful requests cost the published base price of $0.002 per item. Invalid input errors are not charged. The in-browser tool remains free for interactive use.