Challenge: Find the Egyptian Fraction’s Denominators

Solve the challenge of breaking down a positive fraction to its Egyptian fraction denominators.

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 11 and the denominator is a positive integer. For example, 1/31/3 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 2/32/3.

Sample output

result = {2, 6};

These numbers represent the following:

The original number 2/32/3 can be expressed as 1/2+1/61/2 + 1/6. The returned array represents the denominators from both of these numbers, which are 22 and 66.

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.