Re: [go-nuts] Math.big issue

2021-07-11 Thread Rémy Oudompheng
Hello, Fermat's little theorem says that ^5146 mod 5147 is 1 so similarly ^(5146+5146) mod 5147 is also 1. Therefore it is correct that ^(5146+5147) mod 5147 is . If you have a large exponent, you should reduce it modulo (p-1) to keep the same result. Regards, Rémy. Le dim. 11

[go-nuts] Math.big issue

2021-07-11 Thread Paolo C.
I think there is something wrong in big.Int Exp method. This code: func TestExp(t *testing.T) { p := big.NewInt(5147) ab = big.NewInt(5146 + 5147) t.Logf("ab=%d", ab) ab.Mod(ab, p) t.Logf("ab=%d", ab) c := big.NewInt() c_pow_ab := new(big.Int).Exp(c, ab, p) t.Lo