It's a simple problem really, but I have been searching all over and cannot find the answer. Let's assume that we have a list of fractions made using the fractions
module in python:
from fractions import Fraction
A = [Fraction(1, 3), Fraction(4, 14), Fraction(8, 21)]
I want to put them all on one base denominator. The output would be a list of all of the numerators plus the common denominator:
"""
A[0] ==> 7/21
A[1] ==> 6/21
A[2] ==> 8/21
Notice that the denominator 21 is the lowest we can go.
"""
B = [7, 6, 8, 21] # Desired output style
How would I go about doing this in pure python (only using built in libraries).