Reapply modulo helpers and inline fast remainders
This commit is contained in:
1 parent
5db0c4fa95
commit
ca866ffc5b
43 files changed
+982
-134
No files matched your search
@@ -8,12 +8,16 @@ public class MersenneNumberLucasLehmerCpuTester
|
||||
// - If 3 | p and p != 3, then 7 | M_p -> composite.
|
||||
// - If p ≡ 1 (mod 4) and p shares a factor with (p-1), reject fast.
|
||||
// - If p is divisible by divisors specific to numbers ending with 1 or 7, reject fast.
|
||||
if (
|
||||
((exponent % 3UL) == 0UL && exponent != 3UL) ||
|
||||
((exponent % 5UL) == 0UL && exponent != 5UL) ||
|
||||
((exponent % 7UL) == 0UL && exponent != 7UL) ||
|
||||
((exponent % 11UL) == 0UL && exponent != 11UL)
|
||||
)
|
||||
ulong mod3 = exponent.Mod3();
|
||||
ulong mod5 = exponent.Mod5();
|
||||
ulong mod7 = exponent.Mod7();
|
||||
ulong mod11 = exponent.Mod11();
|
||||
if (
|
||||
(mod3 == 0UL && exponent != 3UL) ||
|
||||
(mod5 == 0UL && exponent != 5UL) ||
|
||||
(mod7 == 0UL && exponent != 7UL) ||
|
||||
(mod11 == 0UL && exponent != 11UL)
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class MersenneNumberResidueCpuTester
|
||||
q.Mod10_8_5_3(out ulong r10, out ulong r8, out ulong r5, out ulong r3);
|
||||
// Step residues for q += 2*p
|
||||
twoP.Mod10_8_5_3(out ulong step10, out ulong step8, out ulong step5, out ulong step3);
|
||||
step10 = step10.Mod10();
|
||||
step10 %= 10UL;
|
||||
|
||||
// Allowed last-digit sets for q depending on last digit of M_p
|
||||
// lastIsSeven == true => allow {7,9}
|
||||
|
||||
Reference in new issue
Block a user