Fix quotient and remainder calculation in factor extraction

This commit is contained in:
Marek Lemańczyk committed 2025-10-16 22:01:34 +02:00
1 parent 806dc96f8c
commit ab86fc16fe
1 file changed
+3 -2
+3 -2
View File
@@ -1205,11 +1205,12 @@ internal static partial class PrimeOrderCalculator
continue;
}
// Use DivRem to reuse a single division for the quotient and remainder.
// Derive the remainder from the quotient to avoid an extra division.
int exponent = 0;
while (true)
{
ulong quotient = Math.DivRem(remainingLocal, primeCandidate, out ulong divisionRemainder);
ulong quotient = remainingLocal / primeCandidate;
ulong divisionRemainder = remainingLocal - (quotient * primeCandidate);
if (divisionRemainder != 0UL)
{
break;