Engel Expansion Calculator for Positive Fractions
This Engel expansion calculator converts any positive rational number into its exact product-sum representation.
Run — free
Enter a fraction such as 4/13 and receive the nondecreasing sequence of Engel denominators, the corresponding unit-fraction terms, and a normalized version of the input. Every calculation uses integer arithmetic, so repeating decimal approximations and floating-point rounding cannot change the result. The tool is useful for number theory study, worked examples, symbolic checks, and software tests where a canonical, reproducible expansion matters.
What an Engel expansion represents
An Engel expansion writes a positive real number as a sum whose denominators are cumulative products. If the returned list is a1, a2, a3, the represented value is 1/a1 + 1/(a1 a2) + 1/(a1 a2 a3), continuing in the same pattern for every later entry. For a positive rational input, the process terminates, so the calculator returns a finite list and a finite expression. The denominators are nondecreasing, which gives the representation its characteristic ordered structure. This differs from an ordinary Egyptian fraction decomposition: both use unit fractions, but an Engel expansion constrains every new term through the product of all denominators selected so far. The output therefore includes both the raw denominator list, which is convenient for mathematical work or code, and the expanded product-sum terms, which make the represented value easier to inspect. The input fraction is reduced first, making equivalent inputs such as 8/26 and 4/13 produce the same normalized fraction and the same expansion.
How the exact algorithm works
The calculation starts with the current positive rational value p/q and chooses the next denominator as the ceiling of q/p. That choice is made with integer division, not by converting the fraction to a decimal. The residual is then transformed according to the Engel recurrence: replace p with a times p minus q, retain q, and reduce the resulting fraction by its greatest common divisor. When the new numerator is zero, the expansion is complete. Otherwise, the same steps select the next denominator. Because all numerators, denominators, ceilings, products, and reductions use arbitrary-precision integers, the answer stays exact even when the source values are much larger than JavaScript's safe integer range. The implementation also rejects malformed text, zero, negative values, and a zero denominator instead of guessing what the user meant. Input size and expansion length are bounded to keep execution predictable. These rules make the result deterministic across browsers and API workers: the same valid fraction always yields byte-for-byte equivalent mathematical data.
Reading and using the result
Begin with the denominators field when you need the canonical Engel sequence. Its entries are strings so that very large integers remain exact when the response passes through JSON systems that cannot safely represent every integer as a numeric value. The length field reports how many denominators and therefore how many unit-fraction terms occur. The expansion field multiplies the selected denominators cumulatively and displays each reciprocal, making it straightforward to verify the sum independently with rational arithmetic. For teaching, compare each chosen denominator with the ceiling rule and work through the residual after every step. For software testing, use the normalized fraction and denominator array as stable fixtures, including equivalent unreduced inputs to confirm normalization. Remember that this capability accepts positive fractions only; it does not calculate an infinite expansion for an irrational decimal, interpret mixed-number notation, or approximate a floating-point value. Via the API, each request costs $0.002. The browser and API versions share the same pure solver, so interactive exploration and automated calls follow identical arithmetic rules.
What you can do with it
Check a number theory exercise
Compare a hand-derived Engel denominator sequence with an exact result and inspect the cumulative product terms.
Create deterministic test vectors
Generate stable expected values for rational-arithmetic libraries without depending on floating-point approximations.
Demonstrate rational representations
Show students how the ceiling recurrence turns a positive fraction into an ordered product-sum expansion.
FAQ
What input format is accepted?
Use two positive base-10 integers separated by a slash, such as 4/13. Surrounding whitespace and an optional plus sign are accepted.
Can I enter zero or a negative fraction?
No. An input with a non-positive numerator or denominator returns an invalid-input error.
Why are the denominators returned as strings?
String values preserve arbitrary-precision integers exactly when the result is encoded as JSON.
Is this the same as an Egyptian fraction expansion?
Not exactly. Engel terms have denominators formed by cumulative products of a nondecreasing sequence, which is an additional structural constraint.
Does the calculator use decimal approximations?
No. Parsing, ceiling operations, greatest-common-divisor reductions, and products all use exact integer arithmetic.
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/numth/engel-expansion \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"fraction":"4/13"}'const res = await fetch("https://api.kit.forhosting.com/numth/engel-expansion", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"fraction": "4/13"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/numth/engel-expansion",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"fraction": "4/13"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/numth/engel-expansion", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"fraction":"4/13"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"fraction":"4/13"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/numth/engel-expansion", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"fraction": "4/13"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "numth.engel_expansion",
"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.
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. |