Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 671c995

Browse files
authoredOct 12, 2024··
Create Egyptian Fraction.py
Added a Python Program on Egyptian Fraction Representation
1 parent e9e7c96 commit 671c995

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
 

‎maths/Egyptian Fraction.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def egyptian_fraction(numerator, denominator):
2+
fractions = []
3+
while numerator != 0:
4+
x = denominator // numerator + 1
5+
fractions.append(f"1/{x}")
6+
numerator = x * numerator - denominator
7+
denominator *= x
8+
return fractions
9+
10+
num, den = 6, 14
11+
print(f"Egyptian Fraction of {num}/{den}: {egyptian_fraction(num, den)}")

0 commit comments

Comments
 (0)
Please sign in to comment.