Python, 320703 additions
def divide(a, b): quotient = 0 c = 0 d = 0 while add(d, b) <= a: c = add(c, 1) d = add(d, b) return c
As always, a last-place reference answer. This simply adds 1
to a "quotient" and b
to a "remultiplication" variable until it hits a
.
Here is the debugging code:
add_used = 0def add(a, b): global add_used add_used += 1 return a + bfor a in range(1, 201): for b in range(1, a+1): print "%d / %d = %d" % (a, b, divide(a, b))print "Additions used:", add_used