Egyptian

Egyptian fractions with Python

#!/usr/bin/env python3
import sys
from sympy import Rational
from sympy.ntheory.egyptian_fraction import egyptian_fraction
r=Rational(*map(int,sys.argv[1].split('/')))
e=egyptian_fraction(r)
print(r,"="," + ".join(f"1/{i}" for i in e))

Unknown's avatar

About Linuxgal

Need a spiritual home? Consider joining us at Mary Queen of the Universe Latter-day Buddhislamic Free Will Christian UFO Synagogue of Vishnu
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment