The ancient Egyptians only used fractions of the form 1/n
so any other fraction had to be represented as a sum of such unit fractions and, furthermore, all the unit fractions were different!
What is a good method to make any fraction an egyptian fraction (the less sums better) in C or java, what algorithm can be used, branch and bound, a*?
for example:
3/4 = 1/2 + 1/4
6/7 = 1/2 + 1/3 + 1/42
One way is the greedy algorithm. Given the fraction f
, find the largest Egyptian fraction 1/n
less than or equal to f
(i.e., n = ceil(1/f)). Then repeat for the remainder f - 1/n
, until f == 0
.
So for 3/4, you'd compute:
And for 6/7:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With