The accepted answer by Sabuj Hassan is incorrect, here is a correction. I've also added package invocation_tree to show the invocation tree of recursive function calls:
import invocation_tree as invo_tree # see link above for install instructions
def counts(x, y, z, make):
if(x + y + z > make):
return False # False indicates going over the 'make'
if x + y + z == make:
print(" {} coin$1 , {} coin$2 , {} coin$5".format(x, y//2, z//5))
return True # True indicates matching 'make'
if x == 0 and y == 0: # start with $5, but don't add $5 after adding $2 or $1
counts(x, y, z+5, make)
if x == 0: # then $2, but don't add $2 after adding $1
counts(x, y+2, z, make)
counts(x+1, y, z, make) # then $1
tree = invo_tree.blocking()
tree(counts, 0, 0, 0, 7) # only up to $7 to keep the tree small
After pressing <Enter>
repeatedly this then results in:
Full disclosure: I am the developer of invocation_tree.