Let's consider a list of rational numbers, e.g.
5/102
7/211
88/21
Find an integer A such that it equals to the denominators Least Common Multiple (LCM) only if it does not exceed a given upper bound U, otherwise the closest integer less than U which can be used to represent the list of rational numbers:
X1/A ≈ 5/102
X2/A ≈ 7/211
X3/A ≈ 88/21
being A, X1, X2, X3 integers and X1/A, X2/A, X3/A the closest representation possible of 5/102, 7/211, 88/21.
Using standard Python libraries to solve this problem is fine. It's also possible to use the fractions.Fraction.limit_denominator() function, but of course, limiting each fraction's denominator does not guarantuee that the LCM stays under the chosen upper bound U.