Challenge: Find the Egyptian Fraction
Given a positive fraction, break it down into its Egyptian fractions.
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 1
and the denominator is a positive integer. For example, 1/3
is a unit fraction. Such a representation is called Egyptian fraction.
Input
The inputs are two variables, numerator
and denominator
.
Output
The output is a string in the format n1/d1 , n2/d2 ...
Sample input
numerator: 2
denominator: 3
Sample output
1/2, 1/6
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.