Honor cached cycle when it matches the exponent
This commit is contained in:
1 parent
64c08f9b49
commit
574e4b8007
1 file changed
+12
-13
@@ -80,9 +80,9 @@ public sealed class MersenneNumberDivisorByDivisorCpuTester : IMersenneNumberDiv
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ulong processedCount;
|
ulong processedCount = 0UL;
|
||||||
ulong lastProcessed;
|
ulong lastProcessed = 0UL;
|
||||||
bool processedAll;
|
bool processedAll = false;
|
||||||
|
|
||||||
bool composite = CheckDivisors(
|
bool composite = CheckDivisors(
|
||||||
prime,
|
prime,
|
||||||
@@ -95,7 +95,7 @@ public sealed class MersenneNumberDivisorByDivisorCpuTester : IMersenneNumberDiv
|
|||||||
{
|
{
|
||||||
lock (_sync)
|
lock (_sync)
|
||||||
{
|
{
|
||||||
UpdateStatusUnsafe(processedCount);
|
UpdateStatusUnsafe(lastProcessed, processedCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,20 +238,19 @@ public sealed class MersenneNumberDivisorByDivisorCpuTester : IMersenneNumberDiv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (divisorCycle != 0 && divisorCycle == prime)
|
if (divisorCycle == prime)
|
||||||
{
|
{
|
||||||
|
// A cycle equal to the tested exponent (which is prime in this path)
|
||||||
|
// guarantees that the candidate divides the corresponding Mersenne
|
||||||
|
// number because the order of 2 modulo the divisor is exactly p.
|
||||||
processedAll = true;
|
processedAll = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (divisorCycle == 0)
|
|
||||||
|
if (divisorCycle == 0UL)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Divisor cycle wasn't calculated for ${prime}");
|
Console.WriteLine($"Divisor cycle was not calculated for {prime}");
|
||||||
}
|
}
|
||||||
// if (divisorCycle != 0UL && CheckDivisor(prime, divisorCycle, divisorData) != 0)
|
|
||||||
// {
|
|
||||||
// processedAll = true;
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
divisor += step;
|
divisor += step;
|
||||||
@@ -284,7 +283,7 @@ public sealed class MersenneNumberDivisorByDivisorCpuTester : IMersenneNumberDiv
|
|||||||
return (byte)sum;
|
return (byte)sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateStatusUnsafe(ulong processedCount)
|
private void UpdateStatusUnsafe(ulong lastProcessed, ulong processedCount)
|
||||||
{
|
{
|
||||||
if (processedCount == 0UL)
|
if (processedCount == 0UL)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user