# 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) 
import time,math
N = 1000000000
sum = 0.0
t1 = time.time()
i = 0
while i < N:
  sum = ((sum + 1) * 2 + 1) / 2
  i = i + 1
t2 = time.time()
if math.fabs(sum - 1.5 * N) > 1:
  print "error"
else:
  print "%d operations in %d seconds" % (N, t2 - t1)
