This is a programming challenge to all those avid programmers out there.
An Egyptian fraction is a fraction that can be expressed as a sum of two or more fractions, each with numerator 1. For example, 7/8 = 1/2 + 1/3 + 1/24 (notice all numerators are 1).There may be more than one possible answer. For example, 7/8 could also be equal to 1/2 + 1/4 + 1/8. You must output the one that maximises the first fraction output. Ties are broken by maximising the second fraction, then the third etc.
In the case of 7/8, the correct output should be 1/2 + 1/3 + 1/24
You will be given a numerator value "N" and a denominator value "D" and your programme must output the Egyptian fraction expansion.
Enter N: 31
Enter D: 47
Output: 1/2 + 1/7 + 1/60 + 1/19740
0 < D < N < 50
(Adapted from the South African Programming Olympiad 2002)