0
我明白,为了使这个功能起作用,crtHasSolution必须是真实的,我很难证明n可能是一个解决方案任何想法或提示如何编写或检查haskell?Haskell中国剩余定理
我知道N的条件是它必须大于或等于0且小于m,这是所有mod基的乘积。
crtHasSolution :: [Integer] -> [Integer] -> Bool
crtHasSolution as ms = length as > 0 &&
length ms > 0 &&
length as == length ms &&
all (>=0) as &&
all (>=2) ms &&
pairwise_coprime ms
-- Is a given number a solution to a CRT problem?
-- usage: crtIsSolution n as ms = ans
-- assures: ans == True, if crtHasSolution as ms == True and n is a solution
-- ans == False, otherwise
crtIsSolution :: Integer -> [Integer] -> [Integer] -> Bool
crtIsSolution n as ms = crtHasSolution as ms &&
n >= 0 &&
n < m
where m =
你到目前为止尝试了什么?如果你能展示你的尝试,那么会更好,然后我们会在你卡住的地方帮助你。 – Sibi
如果你看看我已经尝试过的代码图片,但我不知道如果这是正确的 – ale
供将来参考,只需复制/粘贴你的代码,而不是截图它。 – rampion