Sylvester sequence calculator
Each term of Sylvester's sequence is 1 plus the product of all the terms before it: 2, 3, 7, 43, 1807, and the term at position 5 is 3263443. Every digit is kept exact, however large. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- N
- 5
- Value
- 3263443
- Sequence
- 2, 3, 7, 43, 1807, 3263443
Sylvester's sequence is the integer sequence that begins with two and then builds every later term as one plus the product of all earlier terms. Equivalently, each successor satisfies s sub k plus one equals s sub k squared minus s sub k plus one, which yields the familiar prefix two, three, seven, forty-three, one thousand eight hundred seven, and so on. The sequence grows so quickly that ordinary floating-point types and even fixed-width integers fail within a handful of steps, so this calculator uses BigInt arithmetic and returns every value as a decimal string that preserves every digit. You supply a non-negative integer index n under the zero-based convention where n equals zero returns the first term two; negative indices are rejected with a clear validation error rather than a silent wrong answer. When you need more than a single term, enable the optional list flag to receive the entire prefix from s0 through sn as an array of decimal strings.
How Sylvester's sequence is defined and computed
We use the standard zero-based Sylvester indexing with s0 equal to two. Every later term is defined so that s sub n equals one plus the product of s0 through s sub n minus one. That product rule is exactly equivalent to the compact recurrence s sub k plus one equals s sub k times the quantity s sub k minus one, plus one, which rearranges to s squared minus s plus one.
Under that rule s1 is three, s2 is seven, s3 is forty-three, s4 is one thousand eight hundred seven, s5 is three million two hundred sixty-three thousand four hundred forty-three, and subsequent terms explode double-exponentially. The implementation never approximates with floating-point powers or logarithms; instead it walks the recurrence with BigInt multiplies from the first term up to n, which guarantees every digit is exact even when the result has thousands of decimal places.
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 and the same optional sequence.
Where Sylvester numbers show up in real work
Number theory courses introduce Sylvester’s sequence as a canonical example of a product-plus-one recurrence and as a source of pairwise coprime integers whose reciprocals form a greedy Egyptian fraction expansion of one. Product demos, coding interviews, and blog posts about recurrence relations often show a short Sylvester table next to Fibonacci or factorial growth; listing s0 through sn in one call keeps interactive demos honest without reimplementing the loop in every language. Research notes on Egyptian fractions, Sylvester’s sequence coprimality, and double-exponential growth benefit from a single shared reference implementation.
If you later need modular Sylvester terms, pairwise gcd certificates, or Egyptian fraction expansions of a rational, treat those as separate search intents rather than overloading this calculator landing.
FAQ
How is each term related to the previous ones?
Each term equals one plus the product of all previous terms.
Why is value a string instead of a number?
Sylvester numbers grow double-exponentially and leave JavaScript safe integers almost immediately. Decimal strings keep every digit exact.
What happens if n is negative?
Sylvester index n must be non-negative under this convention.
What does it cost?
The browser tool is free and runs locally.
Can I get every term up to n, not just the last one?
Yes. Turn on the option to list the sequence and you get every term from the first one up to position n. For position 5 that is 2, 3, 7, 43, 1807 and 3263443, each written out in full.
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/sylvester-sequence \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":5}'const res = await fetch("https://api.kit.forhosting.com/math/sylvester-sequence", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"n": 5
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/sylvester-sequence",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"n": 5
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/sylvester-sequence", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"n":5}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"n":5}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/sylvester-sequence", 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": 5
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.sylvester_sequence",
"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 | 20 |
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.
How Sylvester's sequence is defined and computed
Returning the value as a decimal string keeps JSON consumers honest: by s7 the number already has twenty-seven digits, and by s10 it has hundreds, far beyond the safe-integer range of ordinary JavaScript numbers. Bounds keep n between zero and twenty inclusive so worst-case latency and memory stay suitable for a free in-browser tool and a lightweight Worker path, while still covering every term you would reasonably write by hand or show in a lecture.
What you send and what you get back
The error for a negative index states that the Sylvester index must be non-negative so form clients and scripts can correct the input without guessing. On success the response always includes the normalized n and value as the exact n-th Sylvester number written in decimal. Provide a required non-negative integer under the field n, or the aliases number or index. The value must be an integer from zero through twenty inclusive; missing fields, non-integers, decimals, and any n below zero are rejected with invalid_input and are not charged. Optionally set list to true (aliases sequence and include_sequence are accepted) to request the full prefix s0 through sn. When list is true, the response also includes sequence: an array of n plus one decimal strings starting with the zeroth term two. Example checks: n equals zero yields value two and, if listed, a single-element sequence; n equals one yields value three; n equals two yields value seven; n equals three yields value forty-three; n equals five yields three million two hundred sixty-three thousand four hundred forty-three; a negative n yields invalid_input. Pricing for successful API calls is the published base of $0.002 per item on the prepaid KIT balance.
Where Sylvester numbers show up in real work
Data and analytics teams occasionally need deterministic super-exponential integer ladders for stress tests of big-integer serializers, JSON size limits, or database column widths; an exact string sequence avoids off-by-one mistakes between 0-based and 1-based codebases once the convention is fixed on the landing page. 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 Sylvester s(n) strings and optional s0..sn prefixes for olympiad problems, programming exercises, and automated answer keys.
Teaching product-plus-one growth
Show students the double-exponential sequence as decimal strings so large terms stay exact and the s0=2 convention is visible, not abstract.
Big-integer stress and serializers
Pull deterministic super-exponential integers into tests of JSON, databases, and BigInt pipelines without reimplementing the recurrence in every service.
Technical questions
What indexing does this Sylvester calculator use?
Zero-based with s0 = 2. Then s1 = 3, s2 = 7, s3 = 43, s4 = 1807, and so on. Negative indices are rejected.