ForHosting KIT · Math

Continued fraction convergents

Enter the partial quotients 3, 7, 15, 1 and you get the convergents 3/1, 22/7, 333/106 and 355/113, each a closer fraction for π. Every step follows the classic recurrence with exact whole numbers. 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
Partial quotients
3, 7, 15, 1
You get
Quantity
4

Continued fractions write a real number as a nested ladder of integer partial quotients, and the successive finite truncations of that ladder are the convergents: the best rational approximations with bounded denominators.

What convergents are and how the recurrence works

Truncating after a0 gives the first convergent h0/k0 = a0/1. Truncating after a1 gives h1/k1 = (a1·a0 + 1)/a1, and each further truncation yields a better rational approximation of the infinite continued fraction. The standard linear recurrence packages this process: seed h−2 = 0, h−1 = 1, k−2 = 1, k−1 = 0, then set hn = an·h(n−1) + h(n−2) and kn = an·k(n−1) + k(n−2) for n from 0 through m.

Every convergent is already in lowest terms when the partial quotients define a simple continued fraction, and consecutive convergents satisfy the determinant identity hn·k(n−1) − h(n−1)·kn = (−1)^(n−1). Classic textbook checks include π ≈ [3; 7, 15, 1] producing 3/1, 22/7, 333/106, 355/113, and the √2 ladder [1; 2, 2, 2, …] producing 1/1, 3/2, 7/5, 17/12, 41/29.

Where convergents are useful

Algebra and number-theory courses ask learners to compute the first few convergents of π, e, or a quadratic irrational by hand; a deterministic oracle lets homework checkers and LMS plugins mark the full sequence without floating-point drift. Competitive programming and Project Euler style problems often need the best rational approximations under a denominator bound, which are exactly the convergents of the continued fraction expansion of the target.

Content sites that rank for continued fraction convergents calculator benefit from a live free browser path that matches the automation path byte-for-byte on the same pure module.

Classroom and homework checks

Students submit partial quotients for π or √2 and verify the full ordered list of convergent fractions against the textbook recurrence.

Exam and LMS auto-grading

Mark continued-fraction items with a deterministic oracle that rejects empty lists and non-integers instead of returning a hollow success.

Diophantine and approximation pipelines

Turn already-known partial quotients into h/k tables for Pell solvers, calendar astronomy, or rational reconstruction steps in notebooks.

What happens if the list is empty?

A continued fraction needs at least one partial quotient; empty input is never treated as a successful zero-length sequence.

What are the convergents of π's continued fraction [3; 7, 15, 1]?

They are 3/1, 22/7, 333/106 and 355/113. Each one comes from cutting the continued fraction one term later, and each approximates π better than the one before it.

How is each convergent calculated?

Multiply the new partial quotient by the previous numerator and add the numerator before that; do the same with the denominators. The ladder starts from fixed values of 0 and 1, so the first convergent is simply the first quotient over 1.

Are the convergents already in lowest terms?

Yes. For a simple continued fraction every convergent comes out already reduced, so 22/7 and 355/113 need no further simplifying. Two consecutive convergents, cross-multiplied, always differ by exactly 1.

Can I enter decimals as partial quotients?

No. Each partial quotient must be a whole number, and a decimal entry or an empty list is refused with a clear message instead of a misleading result. Enter the quotients you already know, such as 1, 2, 2, 2 for the square root of 2.

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/numth/convergents-from-cf

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/numth/convergents-from-cf \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"partial_quotients":[3,7,15,1]}'
{
  "partial_quotients": [
    3,
    7,
    15,
    1
  ]
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "numth.convergents_from_cf",
  "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.

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.

Students meeting π as [3; 7, 15, 1, 292, …], programmers validating Pell equation solvers, and cryptographers inspecting reduced bases all need the same deterministic map from a list of a_i values to the fractions h_n/k_n. This continued fraction convergents calculator accepts a non-empty list of integer partial quotients, runs the classic two-term recurrence with BigInt intermediates, and returns every convergent with numerator, denominator, fraction string, and decimal value. Empty lists and non-integer entries fail with invalid_input so graders and automation never confuse a bad payload with a true empty result.

What convergents are and how the recurrence works

A simple continued fraction is written [a0; a1, a2, …, am] where each a_i is an integer partial quotient. This endpoint materialises that entire sequence in one response so you can display, grade, or feed the fractions into a larger Diophantine pipeline without re-deriving the recurrence in every client language.

Input contract, response shape, and error behaviour

An empty array or an empty string list is rejected with a clear empty-list message rather than returning zero convergents, because an empty continued fraction is not a valid mathematical object for this tool. Lists longer than sixty-four terms are rejected to keep numerators and denominators inside the safe integer domain of the platform. A formula string restates the recurrence for display next to classroom answers. POST a JSON body with the required field partial_quotients: a non-empty array of finite integers (or a single comma-separated string of whole decimals). Aliases quotients, a, cf, terms, and coefficients are accepted for the same list. Each entry may arrive as a JSON number, a BigInt-compatible whole string, or an integer string with an optional leading sign; fractions, scientific notation, empty strings, and non-finite values fail with invalid_input naming the bad index. On success the body echoes partial_quotients, reports count, and returns convergents as an ordered array of objects with index, numerator, denominator, fraction ("h/k"), and value (decimal rounded to twelve places for stable goldens). Intermediate arithmetic uses BigInt; if a numerator or denominator would leave the safe integer range the call fails with invalid_input instead of silently losing precision. Validation failures are not billed; only successful convergent sequences consume the published $0.002 base price.

Where a convergents-from-CF API earns its keep

Research notebooks that already obtained partial quotients from a separate expansion step can call this lightweight parse endpoint instead of pulling a full computer-algebra system only to evaluate the h/k recurrence.

How do I get convergents from a continued fraction?

Send partial_quotients as a non-empty array of integers, for example [3, 7, 15, 1]. The API returns every convergent h_n/k_n with numerator, denominator, fraction string, and decimal value.

Must every partial quotient be an integer?

Yes. Non-integer numbers, scientific notation, and non-numeric strings are rejected with invalid_input naming the offending index.

What recurrence does the calculator use?

The standard seeds h−2=0, h−1=1, k−2=1, k−1=0 and then h_n = a_n·h_{n−1} + h_{n−2}, k_n = a_n·k_{n−1} + k_{n−2} for each index n.

What does the continued fraction convergents calculator cost?

The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.

Read the full KIT documentation →