add comments

This commit is contained in:
filifa
2025-09-30 23:58:28 -04:00
parent 5c42040e34
commit a760093f9d
12 changed files with 62 additions and 3 deletions

View File

@@ -46,6 +46,9 @@ func solveCRT(a1, n1, a2, n2 *big.Int) (*big.Int, *big.Int) {
return x, N
}
/*
Given a system of congruences - defined by slices of remainders and moduli such that x = remainders[i] (mod moduli[i]) for each index i - CRTSolution outputs a solution to the system.
*/
func CRTSolution(remainders, moduli []*big.Int) (*big.Int, *big.Int) {
n1 := new(big.Int)
a1 := new(big.Int)
@@ -63,6 +66,9 @@ func CRTSolution(remainders, moduli []*big.Int) (*big.Int, *big.Int) {
return a1, n1
}
/*
ArePairwiseCoprime returns true if each pair of values in the input slice are coprime.
*/
func ArePairwiseCoprime(moduli []*big.Int) bool {
z := new(big.Int)
for i, a := range moduli {