#### Exercise 81

Create a Python algorithm that calculates the number of ways to pay 10 Euros, using the 1 Euro, 2 Euro and 5 Euro coins.

#### Solution

`# initialize number of ways to 0`

numberOfWays = 0

# Browsing through the integers from 0 to 10 and test if the paid sum 1 * m + 2 * n + 5 * p is equal to 10

for m in range(0,11):

for n in range(0,11):

for p in range(0,11):

if m + 2*n + 5*p == 10:

# display result if 1 * m + 2 * n + 5 * p == 10 when 1 * m + 2 * n + 5 * p == 10

print(str(m) + " * 1 + " , str(n) + " * 2 + ", str(p) + " * 5 " , " = 10 Euros" )

# if 1 * m + 2 * n + 5 * p == 10 if increment the number of ways to pay

numberOfWays = numberOfWays + 1

# display number of ways to paid

print("Finally, Number of ways is : " , numberOfWays)

**Younes Derfoufi**

my-courses.net

my-courses.net