(* 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, sum, i : integer;

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