(* Collection of code snippets by Arne Vajhøj *)
(* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) *)
program Test;

{$APPTYPE CONSOLE}

uses
  Windows,
  SysUtils;

const
  N = 1000000000;

var
  t1, t2, i : integer;
  sum : double;

begin
  t1 := GetTickCount;
  sum := 0;
  for i := 0 to (N - 1) do begin
    sum := ((sum + 1) * 2 + 1) / 2;
  end;
  t2 := GetTickCount;
  if(abs(sum - 1.5*N) > 1) then begin
      writeln('Error');
  end else begin
      writeln(N:1, ' operations in ', ((t2 - t1) div 1000):1, ' seconds');
  end;
end.
