Implement UInt128 exponentiation and apply in Mersenne scan

This commit is contained in:
Marek Lemańczyk committed 2025-09-10 01:51:37 +02:00
1 parent 9eb50bee3b
commit 01277832e6
3 files changed
+63 -9

No files matched your search

+1 -1
View File
@@ -214,7 +214,7 @@ public sealed class MersenneNumberTester(
bool prePrime = true;
UInt128 twoP = (UInt128)exponent << 1; // 2 * p
// UInt128 maxDivisor = new(ulong.MaxValue, ulong.MaxValue);
UInt128 maxK = (UInt128Numbers.Two ^ exponent) / 2 + 1;
UInt128 maxK = UInt128Numbers.Two.Pow(exponent) / 2 + 1;
bool lastIsSeven = (exponent & 3UL) == 3UL;
// This is how maxK was for residue test before changes UInt128 maxK = maxKOverride ?? ResidueMaxK;