In Velthuis.BigIntegers.Primes.pas there is a bug: in the NextProbePrime function the results are always overwrite at the end of the execution block.
function NextProbablePrime(const N: BigInteger; Precision: Integer): BigInteger;
var
Two: BigInteger;
begin
Two := 2;
Result := N;
if Result = Two then
Exit;
if Result.IsEven then
Result := Result.FlipBit(0);
while not IsProbablePrime(Result, Precision) do
begin
Result := Result + Two;
end;
Result := N; //<-----------------------This line should be removed
end;
In Velthuis.BigIntegers.Primes.pas there is a bug: in the NextProbePrime function the results are always overwrite at the end of the execution block.