In England the currency is made up of pound, £, and pence, p, and there are eight coins in general circulation:
1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p).
It is possible to make £2 in the following way:
1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p
How many different ways can £2 be made using any number of coins?
Let's do it non-recursive.
r = 200
c = 0
if r % 200 == 0:
c += 1
for p200 in range(r // 200):
r200 = r - p200 * 200
if r200 % 100 == 0:
c += 1
for p100 in range(r200 // 100):
r100 = r200 - p100 * 100
if r100 % 50 == 0:
c += 1
for p50 in range(r100 // 50):
r50 = r100 - p50 * 50
if r50 % 20 == 0:
c += 1
for p20 in range(r50 // 20):
r20 = r50 - p20 * 20
if r20 <= 0:
break
if r20 % 10 == 0:
c += 1
for p10 in range(r20 // 10):
r10 = r20 - p10 * 10
if r10 % 5 == 0:
c += 1
for p5 in range(r10 // 5):
r5 = r10 - p5 * 5
if r5 % 2 == 0:
c += 1
for p2 in range(r5 // 2):
r2 = r5 - p2 * 2
c += 1
c
print(s)
assert(s == 73682)
print(s)