我正在尝试找出一个数学问题,并且我认为%会让我失望。看看这个:
orWhere
现在在此等式中,如何得到x?当我有
Product::where([
['column','value'],
['another_column','value'],
])->orWhere([
['column','value']
])->get();
答案 0 :(得分:0)
这是Python 3中执行所需功能的代码,如果无法解决,则会引发异常。我使用了不同的变量名称,但这应该不是问题。我不懂javascript,所以我会将Python的翻译留给您。
请注意,您的初始等式已关闭:46 * 2 % 67
实际上等于25
,而不是32
。要求解方程x * 2 % 67 = 25
,请调用divideresidues(25, 2, 67)
,您会得到正确的答案46
。如果您真的想为x
找到y=2, z=67, a=32
,请致电divideresidues(32, 2, 67)
,您会得到正确的答案16
。
def divideresidues(dividend, divisor, modulus):
"""Divide the dividend by the divisor mod modulus. I.e., return the
smallest positive integer solution to the equation
x * divisor % modulus = dividend, assuming dividend and divisor
are positive and less than modulus.
"""
r, newr = modulus, divisor
t, newt = 0, 1
while newr != 0:
quotient, remainder = divmod(r, newr)
r, newr = newr, remainder
t, newt = newt, t - quotient * newt
if t < 0:
t = t + modulus
quotient, remainder = divmod(dividend, r)
if remainder:
raise ValueError('Bad division in divideresidues()')
return t * quotient % modulus