Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Use Fraction solution in Clear category for Fractions Addition by U.V
from fractions import Fraction
def add_fractions(fracts):
s = sum((Fraction(a, b)) for a, b in fracts)
i = int(s)
d = s - i
if i :
return s.numerator if s.denominator == 1 else f'{i} and {d.numerator}/{d.denominator}'
return f'{s.numerator}/{s.denominator}'
Jan. 4, 2023