Egypt

Express a rational number as the sum of unit fractions
import sys from fractions import Fraction as frac from sympy import Rational from sympy.ntheory.egyptian_fraction import egyptian_fraction n = int(sys.argv[1]) d = int(sys.argv[2]) rat=frac(n,d) egypt=egyptian_fraction(Rational(rat)) print(str(rat) + ' = 1/' + str(egypt[0]), end = '') for i in range(1,len(egypt)): print(' + 1/',str(egypt[i]), sep ="", end = '') print
 * 1) !/usr/bin/python3