terican

Last verified · v1.0

Calculator · math

Egyptian Fraction Calculator (Greedy / Fibonacci–Sylvester)

Expand any fraction p/q into distinct unit fractions using the greedy algorithm. Instant step-by-step Egyptian fraction decomposition.

FreeInstantNo signupOpen source

Inputs

Number of Unit Fractions

Explain my result

0/3 free

Get a plain-English breakdown of your result with practical next steps.

Number of Unit Fractionsterms

The formula

How the
result is
computed.

What Are Egyptian Fractions?

An Egyptian fraction is a representation of a positive rational number as a finite sum of distinct unit fractions — fractions of the form 1/n where n is a positive integer. Ancient Egyptian scribes used this notation exclusively, as documented in the Rhind Mathematical Papyrus (circa 1650 BCE). For example, 3/4 was written as 1/2 + 1/4, and 2/5 as 1/3 + 1/15. The requirement that all denominators be distinct is the defining constraint separating Egyptian fractions from ordinary unit-fraction sums.

The Greedy Algorithm (Fibonacci–Sylvester Method)

The most systematic algorithm for computing Egyptian fraction expansions is the greedy algorithm, first described by Fibonacci in his 1202 treatise Liber Abaci and later formalized by James Joseph Sylvester in 1880. At each step the algorithm selects the largest possible unit fraction that does not exceed the remaining value, hence the name greedy. This approach is also called the Fibonacci–Sylvester algorithm in recognition of both contributors.

Core Formula

Given a proper fraction p/q where p and q are positive integers and p < q, the algorithm applies the following recurrence:

  • Step 1 — Compute the ceiling: Let n = ⌈q/p⌉, the smallest positive integer such that 1/n ≤ p/q.
  • Step 2 — Record the unit fraction: Append 1/n to the expansion list.
  • Step 3 — Compute the remainder: The new fraction equals (p·n − q)/(q·n), derived directly from p/q − 1/n = (p·n − q)/(q·n).
  • Step 4 — Iterate: Set p ← p·n − q and q ← q·n (after reducing by GCD), then return to Step 1 until the remainder equals zero.

Guaranteed Termination

The algorithm always terminates in a finite number of steps. When p does not divide q, the new numerator p·⌈q/p⌉ − q is strictly less than p, because ⌈q/p⌉ < q/p + 1 in that case, giving p·⌈q/p⌉ − q < p. Since the numerator is a positive integer that strictly decreases each iteration, it must eventually reach zero. When p divides q the remainder is zero immediately. This termination proof is detailed in Wolfram MathWorld: Egyptian Fraction.

Worked Example: Expanding 5/7

Apply the greedy algorithm to 5/7 step by step:

  • Iteration 1: ⌈7/5⌉ = 2. Unit fraction: 1/2. Remainder: (5×2 − 7)/(7×2) = 3/14.
  • Iteration 2: ⌈14/3⌉ = 5. Unit fraction: 1/5. Remainder: (3×5 − 14)/(14×5) = 1/70.
  • Remainder zero — done. Result: 5/7 = 1/2 + 1/5 + 1/70.

Verification: 35/70 + 14/70 + 1/70 = 50/70 = 5/7. Correct.

The Fibonacci–Sylvester Sequence

Applying the greedy algorithm to the number 1 generates the Sylvester sequence: 2, 3, 7, 43, 1807, 3263443, ... Each term satisfies the recurrence a_{n+1} = a_n(a_n − 1) + 1, and the sum of reciprocals converges exactly to 1: 1/2 + 1/3 + 1/7 + 1/43 + 1/1807 + ··· = 1. The sequence grows doubly exponentially — each term is roughly the square of the previous — so only a handful of terms suffice to represent most fractions to high precision.

Key Variables

  • p (Numerator): The top number of the input fraction. For a proper Egyptian fraction expansion p must be less than q. The algorithm's termination guarantee rests on p being a positive integer that strictly decreases each iteration.
  • q (Denominator): The bottom number of the input fraction; must be a positive integer. Fractions with large or irregular denominators may produce expansions whose later unit-fraction denominators grow very large.
  • ⌈q/p⌉ (Ceiling): The ceiling function rounds q/p up to the nearest integer and identifies the greedy unit fraction 1/⌈q/p⌉ — the largest unit fraction not exceeding the current remainder.

Applications and Open Problems

Egyptian fractions remain an active research area in number theory. The Erdős–Straus conjecture (1948) asserts that for every integer n ≥ 2 the fraction 4/n can be expressed as the sum of exactly three unit fractions; it has been verified computationally for all n up to 10^14 but remains unproven in general. Egyptian fraction decompositions also appear in fair division problems, where distinct shares of a resource must be allocated without repetition, and in combinatorial analysis of rational numbers. The OSU survey Egyptian fractions, Sylvester's sequence, and the Erdős–Straus conjecture provides an accessible yet rigorous treatment of these connections.

Limitations of the Greedy Algorithm

The greedy algorithm always produces a valid expansion but does not guarantee the shortest one or the one with the smallest denominators. For some fractions, other methods yield fewer terms. For instance, the greedy expansion of 4/17 produces denominators reaching into the millions, while a manual search finds 4/17 = 1/5 + 1/29 + 1/1233 with comparable length but different denominators. For applications where compact representations matter, exhaustive search or splitting algorithms may be preferable over the greedy approach.

Reference

Frequently asked questions

What is an Egyptian fraction and why is it called that?
An Egyptian fraction is a representation of a positive rational number as a sum of distinct unit fractions — fractions whose numerator is exactly 1, such as 1/2, 1/5, or 1/13. The name comes from ancient Egyptian mathematical practice documented in the Rhind Mathematical Papyrus (circa 1650 BCE), where scribes expressed quantities like 3/5 as 1/2 + 1/10 rather than using general numerators. The uniqueness rule requiring distinct denominators is what defines the representation.
How does the greedy algorithm calculate an Egyptian fraction expansion step by step?
The greedy algorithm takes a fraction p/q, computes the ceiling ⌈q/p⌉ to identify the largest available unit fraction not exceeding p/q, records 1/⌈q/p⌉, then subtracts it to get the remainder (p·⌈q/p⌉ − q)/(q·⌈q/p⌉) and repeats. For 3/7: ⌈7/3⌉ = 3 gives 1/3; remainder 2/21; ⌈21/2⌉ = 11 gives 1/11; remainder 1/231. Result: 3/7 = 1/3 + 1/11 + 1/231. The numerator decreases every step, so the process always terminates.
What is the Fibonacci–Sylvester sequence and how does it relate to Egyptian fractions?
The Fibonacci–Sylvester sequence (2, 3, 7, 43, 1807, 3263443, ...) arises from applying the greedy Egyptian fraction algorithm to the number 1. Each term satisfies the recurrence a_{n+1} = a_n(a_n − 1) + 1, and the sum of corresponding unit fractions 1/2 + 1/3 + 1/7 + 1/43 + ··· equals exactly 1. Fibonacci described this process in his 1202 work Liber Abaci; Sylvester gave it formal treatment in 1880. The sequence grows doubly exponentially, making convergence extremely rapid.
Does every positive rational number have an Egyptian fraction representation?
Yes — every positive rational number has at least one Egyptian fraction representation, and in fact infinitely many. The greedy algorithm provides a constructive proof: because the numerator strictly decreases at each iteration and is always a positive integer, the algorithm must halt in finitely many steps, producing a valid sum of distinct unit fractions. For rational numbers greater than 1, the integer part is extracted first and the proper-fraction remainder is then expanded via the algorithm.
What is the Erdős–Straus conjecture and why does it matter for Egyptian fractions?
The Erdős–Straus conjecture (1948) proposes that for every integer n ≥ 2, the fraction 4/n can be written as the sum of exactly three unit fractions: 4/n = 1/a + 1/b + 1/c. It has been verified computationally for all n up to 10^14 but no general proof exists. The conjecture is significant because it shows how elementary-looking questions about Egyptian fraction decompositions — specifically, whether a bounded number of terms always suffices — can remain open for more than 75 years despite extensive effort.
Why does the greedy algorithm sometimes produce very large denominators?
The greedy algorithm prioritizes the largest available unit fraction at each step, which reduces the current remainder efficiently but can push subsequent remainders into fractions with very large denominators. Expanding 5/121 using the greedy method, for example, can produce a denominator exceeding one million within two iterations. This is a fundamental trade-off of the greedy approach: it always terminates in few steps (since the numerator decreases), but the denominators in later terms can grow rapidly. Alternative algorithms sometimes yield more compact representations with smaller denominators.