ForHosting KIT · Math

Lucas number calculator: L_n from L0=2, L1=1, free bigint

Get any term of the Lucas sequence exactly: it starts 2, 1, 3, 4, 7, 11, and the 10th term is 123. Ask for an index up to 10000 and receive every digit, with no rounding, plus 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
Use it from WebAPIEmailTelegramApp soon
If you enter
N
10
You get
Lucas
123
Digits
3
Max n
10,000

The Lucas number calculator returns the n-th term of the Lucas sequence, the classic companion of the Fibonacci numbers. By definition L0 equals two, L1 equals one, and every later term is the sum of the two terms before it, so the beginning of the sequence is two, one, three, four, seven, eleven, eighteen, twenty-nine, and so on. Give a non-negative integer index n and the tool returns that Lucas 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 Lucas numbers fit in study, code, and teaching

Students meet Lucas numbers when a textbook contrasts them with Fibonacci, when a worksheet asks for L_n for a modest n, or when they verify identities such as L_n equals F_{n-1} plus F_{n+1} for positive n. 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 Lucas number rather than an approximate closed form. Contest practice often needs a fast, offline source of ranked Lucas values so solutions can be checked without downloading OEIS tables under time pressure.

Science communicators use short Lucas sequences as a clean example of a linear recurrence with integer seeds that still grows exponentially, which pairs well with plots of digit counts against n.

Homework and exam preparation

Look up exact L_n values and optional full prefixes for textbook exercises and contest problems that list Lucas numbers by index.

What does the Lucas number calculator cost?

It is free in your browser on this page.

What are L0 and L1?

L0 is 2 and L1 is 1. Later terms follow Ln = L(n-1) + L(n-2).

How do I get the full sequence up to Ln?

The response then includes a sequence array of decimal strings from L0 through Ln.

How are Lucas numbers related to Fibonacci numbers?

They follow the same rule, each term being the sum of the two before it, but they start from different seeds: 2 and 1. For any positive n, the n-th Lucas number equals the sum of the Fibonacci numbers just before and just after position n.

How large an index can I ask for?

Any whole number from 0 to 10000. The answer is written out in full, with no rounding, and the calculator also tells you how many digits it has: the 10th Lucas number, 123, has 3.

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.

POSThttps://api.kit.forhosting.com/math/lucas-number

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.

curl -X POST https://api.kit.forhosting.com/math/lucas-number \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"n":10}'
{
  "n": 10
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "math.lucas_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.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_n10000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

What Lucas numbers are and what the response contains

They share the same linear recurrence as the Fibonacci numbers but start from different seeds, which gives them a different closed form and a different OEIS entry while remaining just as useful for teaching recurrence relations, generating functions, and BigInt iteration. This calculator returns the requested index n, the Lucas value as a decimal string under the field lucas, 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 L0 through Ln inclusive, so you never have to reconstruct the prefix yourself. If you need Fibonacci numbers, primes by rank, or Collatz orbits, use those dedicated tools; this page answers only the Lucas rank-to-value question with optional sequence listing. Lucas numbers form the integer sequence defined by L0 = 2, L1 = 1, and Ln = L(n-1) + L(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 Lucas sequence is indexed from zero upward, and a negative n is treated as a client error rather than an extension via the signed Lucas formula.

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 Lucas number. Zero is valid and returns two, because L0 is defined as two in the classical sequence. Computation is a simple iterative loop: start from BigInt two and BigInt one, then repeatedly replace the pair with the next sum 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 Lucas 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 an nth-prime calculator when you need primes by rank, with Collatz when you need hailstone orbits, and with other math and number-theory tools when you are building a small lab of free, deterministic endpoints.

Deterministic test fixtures

Generate reproducible Lucas strings for unit tests, property checks, and CI assertions without embedding large static tables.

Teaching recurrences and BigInt

Show how a two-term recurrence with L0=2 and L1=1 grows, and how decimal-string output keeps every digit exact past safe integers.

Can I request a negative index?

No. Negative n is rejected with invalid_input. This calculator defines Lucas numbers for n greater than or equal to zero only.

Why is the result a string instead of a number?

Large Lucas numbers exceed JavaScript safe integers. Returning a decimal string keeps every digit exact in JSON and in the browser.

Read the full KIT documentation →