about | help | code help+videos | done | prefs |
You should read about Egyptian Fractions first: https://en.wikipedia.org/wiki/Egyptian_fraction Write a method that returns the "hungry" form of an Egyptian Fraction for the given numerator and denominator. The term "hungry" is something I just made up (I think). It means that you keep taking out the largest valued fraction possible. For example, 17/30 becomes 1/2+1/16+1/241+1/57841 because you first take out 1/2 which is the largest fraction less than 17/30 with a unit numerator. Then you take out 1/16 because it is the largest remaining unit numerator fraction. This process continues until you have a sum that is equal to the original fraction (or at least within the tolerance described next). Note: Your answer does NOT have to be EXCATLY equal to the original fraction! You just need to be within 0.00000001 of the original value. test2021_11_18_HL_egyptianFract(3, 10) → "1/4+1/21+1/421+1/176821" test2021_11_18_HL_egyptianFract(8, 20) → "1/3+1/15" test2021_11_18_HL_egyptianFract(2, 17) → "1/9+1/153" ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy