The greedy algorithm for Egyptian fractions, first described in 1202 by Fibonacci in his book "Liber Abaci", finds an expansion in which each successive term is the largest unit fraction that is no larger than the remaining number to be represented. For fractions of the form or , the greedy algorithm uses at most two or three terms respectively. A number of the form has a two-term expansion if and only if has a factor congruent to modulo , and requires three terms in any expansion otherwise.