Challenge: Find the Egyptian Fraction’s Denominators
Solve the challenge of breaking down a positive fraction to its Egyptian fraction denominators.
We'll cover the following
Problem statement
Every positive fraction can be represented as the sum of its unique unit fractions. A fraction is a unit fraction if the numerator is and the denominator is a positive integer. For example, is a unit fraction. Such a representation is called an Egyptian fraction.
Input
Two variables: numerator
and denominator
.
Output
An array of denominators in the format [d1, d2, ..., dn]
.
Sample input
numerator = 2;
denominator = 3;
This value represents the number .
Sample output
result = {2, 6};
These numbers represent the following:
The original number can be expressed as . The returned array represents the denominators from both of these numbers, which are and .
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.