There is a minor bug in the pseudo-code in my previous post which

was deliberately put there to see if anyone was paying attention

If we start with p=1, that is we already have a unit/Egyptian fraction we

are at the mercy of how we interpret a "Repeat until" loop. If we test at

the top of the loop we will not get the right result under these conditions.

I think the following should correct the problem.

Code:

**assume:** p, q positive integers such that p/q is a rational in lowest terms <1.
let n be the largest integer such that 1/n<=p/q, and R=p/q-1/n
EF=[n] //list form Egyptian fraction with one entry
Repeat while R<>0
let n be the largest integer such that 1/n<=R, and R=R-1/n
EF=EF|n //concatenate n to EF
end
**assert:** EF is an Egyptian fraction representation of p/q

or:

Code:

**assume:** p, q positive integers such that p/q is a rational in lowest terms <1.
let n be the largest integer such that 1/n<=p/q, and R=p/q-1/n
EF=[] //null list form Egyptian fraction
if R==0 then
EF=[n]
else
Repeat
EF=EF|n //concatenate n to EF
let n be the largest integer such that 1/n<=R, and R=R-1/n
Until R==0
endif
**assert:** EF is an Egyptian fraction representation of p/q

RonL