anchor.diff:  var
     R: Integer;
     D: BigInteger;
  -//  Estimate: BigInteger;
  -//  NewEstimate: BigInteger;
  -//  I: Integer;
   begin
     //  Write N - 1 as (2 ^ Power) * Factor, where Factor is odd.
     //  Repeatedly try to divide N - 1 by 2
  
positive.code:   I: Integer;
    PrimesToTest: Integer;
    D: BigInteger;
  const
    CPrimesToTest: array[0..6] of Integer = (2, 3, 5, 7, 11, 13, 17);
    CProbabilityResults: array[Boolean] of TPrimality = (primComposite, primProbablyPrime);
  
    function GetNumberOfPrimesToTest(const N64: Int64): Integer;
    begin
      if N64 > Int64(3474749660383) then
        Result := 7
      else if N64 > Int64(2152302898747) then
        Result := 6
      else if N64 > Int64(118670087467) then
        Result := 5
      else if N64 > Int64(25326001) then
        Result := 4
      else if N64 > Int64(1373653) then
        Result := 3
      else
        Result := 2;
    end;
  
  begin
    if N > BigInteger('341 550 071 728 321') then
      Exit(CProbabilityResults[IsProbablePrime(N, Precision)]);
  
    PrimesToTest := GetNumberOfPrimesToTest(Int64(N));
    if N = 3215031751 then
      Exit(primComposite);
  
    D := N;
    Dec(D);
    R := 0;
  
    while D.IsEven do
  
negative.code: 
  /// <summary>Returns a random probably prime number.</summary>
  /// <param name="NumBits">Maximum number of bits of th random number</param>
  /// <param name="Precision">Precision to be used for IsProbablePrime</param>
  /// <returns> a random prime number that is probably prime with the given precision.</returns>
  function RandomProbablePrime(NumBits: Integer; Precision: Integer): BigInteger;
  
  