import sys

h      = 0.01
n      = 100
answer = 1.0
eps    = 1.0e-10

argv = sys.argv
if len(argv) >= 2:
    h = float(argv[1])
if len(argv) >= 3:
    n = int(argv[2])
if len(argv) >= 4:
    answer = float(argv[3])

v = 0.0
i = 0
while i < n:
    v = v + h
    i = i + 1

print()
print("Adding h repeatedly:")
print("  h =", h)
print("  n =", n)
print("  result v =", v)
print()

print("Exact comparison:")
print("  v == answer :", (v == answer))

diff = v - answer
if diff < 0:
    diff = -diff

print("Tolerance check:")
print("  |v - answer| < eps :", (diff < eps))
print()
