Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 539
ModSolver finds a solution of the equation a* x = b mod n
def ModSolver(a,b,n): testxgcd = xgcd(a,n) if testxgcd[0]!=1: print "a and n are not coprime" return None ainv = testxgcd[1] return (ainv*b)%n A=3687643928749827493284733847932849326478268265438567836493287498237498327493273684983729400073294873001 B=4356483636578364578346584638564385643875643856478365874365874365834001 N=3246387264832647832643924793287439827493827493287498327492374036483684362803428768326583653457347325473254730001 X=ModSolver(A,B,N) X
3193344696006285988199840326650376758798369858174091258235893436186808593260532708688549688263925514745711729468
A*X %N B
4356483636578364578346584638564385643875643856478365874365874365834001 4356483636578364578346584638564385643875643856478365874365874365834001
xgcd(71,73)
(1, 36, -35)