Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The ancient Egyptians could easily handle simple fractions, but with one remarkable peculiarity. The only fractions these ancients used were 2/3 and the reciprocals of
The ancient Egyptians could easily handle simple fractions, but with one
remarkable peculiarity. The only fractions these ancients used were 2/3 and the reciprocals of the integers, the so-called unit fractions (1/n) with each numerator equal to 1. Curious though this treatment of fractions may seem to us, no doubt it seemed both natural and easy to the ancients. Thus their answer to the problem, 'divide seven loaves among ten men' was not 7/10 of a loaf each, but the sum of fraction 1/2 + 1/5. Can all proper fractions be expressed as the sum of unit fractions, without repetition? Yes, as Fibonacci showed in his Liber Abaci, where he described what is now called the greedy algorithm. For this example the greedy algorithm is to repeatedly subtract the largest possible unit fraction, then do the same again, and so on. We find that most fractions can be represented compactly in this manner, and Sylvester proved in 1880 that applying a greedy algorithm to the fraction p/q, where p is less than q, always produces a sequence of terms with no more than p unit fractions. Write a python program from scratch which reads two integers p and q from a user and outputs a listing representing a sum of no more than p unit fractions, with sum equal to p/q. Here is a sample run: p? 11 q? 12 1/ 2 + 1/ 3 + 1/ 12 = 11/12
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started