Pell number calculator
P10 is 2378: each Pell number is twice the previous one plus the one before, starting 0, 1, 2, 5, 12, 29. Enter an index up to 10000 to get the exact term, with every digit, and the full list if you want it. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- N
- 10
- Pell
- 2378
- Digits
- 4
- Max n
- 10,000
The Pell number calculator returns the n-th term of the Pell sequence, a classic integer recurrence closely related to the continued fraction of the square root of two and to solutions of Pell’s equation. By definition P0 equals zero, P1 equals one, and every later term is twice the previous term plus the term before that, so the beginning of the sequence is zero, one, two, five, twelve, twenty-nine, seventy, one hundred sixty-nine, and so on. Give a non-negative integer index n and the tool returns that Pell number exactly as a decimal string, so values far beyond JavaScript safe integers stay correct. The engine uses deterministic BigInt arithmetic with no floating-point shortcuts, no random sampling, and no network call.
Where Pell numbers fit in study, code, and teaching
Students meet Pell numbers when a textbook links them to continued fractions of sqrt(2), when a worksheet asks for P_n for a modest n, or when they explore solutions of x squared minus two y squared equals plus or minus one. Teachers can pre-generate answer keys and full prefixes for a problem set without trusting opaque calculator apps that round large integers.
Developers call the same contract from scripts to seed deterministic test vectors, to illustrate BigInt-safe serialization in APIs, or to satisfy programming-challenge statements that demand the exact n-th Pell number rather than an approximate closed form. Contest practice often needs a fast, offline source of ranked Pell values so solutions can be checked without downloading OEIS tables under time pressure.
Science communicators use short Pell sequences as a clean example of a linear recurrence with a coefficient two that still yields pure integers, which pairs well with plots of digit counts against n.
What you can do with it
Homework and exam preparation
Look up exact P_n values and optional full prefixes for textbook exercises and contest problems that list Pell numbers by index.
Teaching recurrences and BigInt
Show how a two-term recurrence with coefficient two grows, and how decimal-string output keeps every digit exact past safe integers.
FAQ
What does the Pell number calculator cost?
It is free in your browser on this page.
How do I get the full sequence up to Pn?
The response then includes a sequence array of decimal strings from P0 through Pn.
How far up the sequence can it go?
Up to index 10000. Every term up to there comes back exactly, as a full string of digits, because the calculation uses whole-number arithmetic with no rounding. The number of digits is shown next to the result.
How is the Pell sequence different from Fibonacci?
Both build each term from the two before it, but Pell counts the previous term twice: twice the last term plus the one before it. That factor of two makes the terms grow roughly like (1 + √2) raised to the power n.
Can I use a negative index?
No. The index must be a whole number from 0 upward; negative values, fractions and numbers in scientific notation are refused rather than guessed. P0 is 0 and P1 is 1.
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/pell-number \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":10}'const res = await fetch("https://api.kit.forhosting.com/math/pell-number", {
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/pell-number",
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/pell-number", 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/pell-number", 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.pell_number",
"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_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
What Pell numbers are and what the response contains
They grow roughly like (1 + sqrt(2))^n, appear in closed forms involving the silver ratio, and sit beside companion Pell-Lucas numbers in number-theory tables, while remaining straightforward to teach as a two-term linear recurrence with a coefficient other than one. This calculator returns the requested index n, the Pell value as a decimal string under the field pell, the number of digits in that string, and the published maximum supported n so clients can validate before they send a batch. When you set the optional sequence flag to true, the response also includes an array of decimal strings for P0 through Pn inclusive, so you never have to reconstruct the prefix yourself. If you need Fibonacci numbers, Lucas numbers, primes by rank, or Collatz orbits, use those dedicated tools; this page answers only the Pell rank-to-value question with optional sequence listing. Pell numbers form the integer sequence defined by P0 = 0, P1 = 1, and Pn = 2 times P(n-1) plus P(n-2) for every n at least two. There is no approximate floating-point formula presented as truth and no sampling of random primes: the engine either builds the exact term inside the supported range or rejects the input with invalid_input. Rejected cases include missing n, non-integers, fractions, scientific notation, values above the documented ceiling, and any negative index. That last rule is intentional: the standard Pell sequence is indexed from zero upward, and a negative n is treated as a client error rather than an extension via signed or reverse recurrences.
How the index is read and how BigInt keeps every digit exact
Optional leading plus signs are allowed; embedded spaces, hex prefixes, negative signs, and exponential notation are rejected with a clear message so a bad cell does not become a wrong Pell number. Zero is valid and returns zero, because P0 is defined as zero in the classical sequence. Computation is a simple iterative loop: start from BigInt zero and BigInt one, then repeatedly replace the pair with next equals two times the current term plus the previous term until the requested index is reached. The preferred field is n as a JSON integer, but decimal strings and the aliases index and k are accepted so spreadsheets, query strings, and typed forms can reuse the same contract. The engine enforces a hard maximum of ten thousand on n, which keeps memory and latency inside a predictable budget on the free browser path and on the edge Worker even when the sequence flag is enabled and every intermediate term is collected. Every term is stored as a BigInt and serialized with toString so JSON never loses digits the way IEEE doubles would after the fifty-third bit. The optional sequence boolean also accepts common string forms such as true, false, yes, and no for form-friendly callers. Pair the free browser run on this page with the priced API when you need the identical mathematical result inside an automated pipeline without re-implementing the recurrence yourself.
Where Pell numbers fit in study, code, and teaching
On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the mathematical result. Pair it with a Lucas calculator when you need companion sequences, with an nth-prime tool when you need primes by rank, and with other math and number-theory tools when you are building a small lab of free, deterministic endpoints.
Integration use cases
Deterministic test fixtures
Generate reproducible Pell strings for unit tests, property checks, and CI assertions without embedding large static tables.
Technical questions
What are P0 and P1?
P0 is 0 and P1 is 1. Later terms follow Pn = 2*P(n-1) + P(n-2). Sending n = 0 returns 0; n = 1 returns 1.
Can I request a negative index?
No. Negative n is rejected with invalid_input. This calculator defines Pell numbers for n greater than or equal to zero only.
Why is the result a string instead of a number?
Large Pell numbers exceed JavaScript safe integers. Returning a decimal string keeps every digit exact in JSON and in the browser.