Primorial calculator
Multiply every prime up to n and get the exact result: 10# is 2 × 3 × 5 × 7, which is 210, along with the list of primes and how many there are. Every digit stays exact for any n up to 10000. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Non-negative integer upper bound
- 10
- Value
- 210
- Product
- 210
- Primes
- 2, 3, 5, 7
- Quantity
- 4
The primorial of a non-negative integer n, written n#, is the product of every prime number less than or equal to n. It is the prime-number analogue of the factorial: instead of multiplying all positive integers up to n, you multiply only the primes that fall at or below that bound. Primorials appear in proofs about prime gaps, constructions of highly composite-related bounds, primality heuristics, and contest problems that need the product of the first primes without floating-point drift. This calculator sieves primes up to n and multiplies them with exact BigInt arithmetic, returning the full decimal string along with the list of primes and their count. For n less than two there are no primes at or below n, so the empty product is one by the standard multiplicative convention. Negative inputs and non-integers are rejected with a clear validation error rather than a silent wrong answer.
How the primorial n# is defined and computed
The primorial n# is defined as the product of all prime numbers p such that p is less than or equal to n. When n is zero or one, that set is empty and the empty product equals one, just as zero factorial is defined as one.
For n equals two the only prime is two and the primorial is two; for n equals three the primes are two and three and the product is six; for n equals four the primes are still only two and three so the primorial stays six; for n equals five the product becomes thirty; for n equals seven it is two hundred ten; for n equals eleven it is two thousand three hundred ten.
Growth is super-exponential in the digit sense because each new prime multiplies the running product by a larger factor, and by the prime-number theorem the logarithm of n# is about n, so the digit length grows roughly like n over the natural log of ten.
This implementation never uses floating-point approximation, probabilistic primality tests for the sieve range, or external tables: it runs a classic sieve of Eratosthenes up to n, collects every prime flag that remains true, and multiplies those primes in order with BigInt so every intermediate and final digit is integer-exact. The path is fully deterministic—no random seeds, no clocks, no network, and no model drift—so the same n always yields the same string, the same prime list, and the same count.
Where exact primorials show up in real work
Cryptography and security educators sometimes illustrate how products of small primes behave under modular arithmetic and how primorials relate to primality bounds; an exact string check confirms slide examples before students implement their own sieves. Product demos and interview prep often show a short primorial table next to a factorial table so candidates can contrast the two products; computing n# in one call keeps interactive demos aligned with textbooks.
If you later need the product of the first k primes as a separate indexed sequence, prime counting alone, factorial, or primality of a single large integer, treat those as separate search intents rather than overloading this primorial calculator landing.
What you can do with it
Teaching primes versus factorials
Show students how n# multiplies only primes ≤ n while n! multiplies every integer, with exact strings so large terms stay correct next to textbook tables.
Library and sieve sanity checks
Confirm sieve implementations, prime-product helpers, or number-theory libraries against a trusted BigInt primorial before shipping numeric code.
FAQ
What is the primorial n#?
n# is the product of all prime numbers less than or equal to n. For example 5# = 2×3×5 = 30 and 10# = 2×3×5×7 = 210. This tool returns that exact product as a decimal string.
How is primorial different from factorial?
Factorial n! multiplies every positive integer up to n. Primorial n# multiplies only the primes ≤ n. Both use an empty-product convention of 1 when there is nothing to multiply (0! = 1 and 0# = 1# = 1).
Why is the product a string instead of a number?
Primorials grow past JavaScript safe integers quickly. Decimal strings keep every digit exact for large n.
What happens if n is negative or not an integer?
Primorial here is defined only for non-negative integers; negatives and decimals are rejected and not charged.
What does it cost?
The browser tool is free and runs locally.
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/primorial \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":10}'const res = await fetch("https://api.kit.forhosting.com/math/primorial", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"n": 10
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/primorial",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"n": 10
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/primorial", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"n":10}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"n":10}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/primorial", 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": 10
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.primorial",
"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
min_n | 0 |
max_n | 10000 |
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
The free browser tool and the paid API share one pure function, so classroom demos and automated pipelines never silently diverge on the same n.
How the primorial n# is defined and computed
Returning the product as a decimal string keeps JSON consumers honest: large primorials leave the safe-integer range of ordinary JavaScript numbers quickly, and a numeric type would silently round. Bounds keep n between zero and ten thousand so worst-case latency stays suitable for a free in-browser tool and a lightweight Worker path, while still covering contest, classroom, and pipeline needs for exact large prime products.
What you send and what you get back
The error for negative n states that primorial is defined for non-negative integers so form clients and scripts can correct the input without guessing. On success the response always includes the normalized n, product and value as the exact n# written in decimal (both fields carry the same digit string for convenience), primes as the ordered list of prime factors multiplied, and count as the length of that list which equals π(n) for n at least zero. Provide a required non-negative integer under the field n, or the aliases number, value, or limit. The value must be an integer from zero through ten thousand inclusive; missing fields, non-integers, decimals, and any n below zero are rejected with invalid_input and are not charged. Example checks: n equals zero yields product one and an empty prime list; n equals five yields product thirty and primes two, three, five; n equals ten yields product two hundred ten; n equals thirteen yields product thirty thousand thirty; n equals negative one yields invalid_input; n equals three point five yields invalid_input. Pricing for successful API calls is the published base of $0.002 per item; validation failures do not consume prepaid balance.
Where exact primorials show up in real work
Because this capability is a pure parse engine, API pricing is the published base of $0.002 per successful item and failed validation does not consume balance.
Integration use cases
Contest and homework fixtures
Generate exact n# decimal strings and prime factor lists for olympiad problems, programming exercises, and automated answer keys that reject floating-point drift.