Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
If 4 and 7 in the example are two parameters of the equation (a and b, respectively), taking only positive integer values, then without enumeration - easily:
def solve_equation(a,b): # x - a(x div b) = b
if a%1 + b%1 != 0:
raise ValueError('both variables must have integer values')
if 0 < a < b: x = a + b
else: x = None
return x
In the sense that for any a < b the answer is: a + b. For all others, there is no solution.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question