How many ways you can make change for an amount N using A and B monets.

103 Views Asked by At

I encountered a quite interesting problem. The question is: How many ways you can make change for an amount N using monets of value A and B, knowing that GCD(A,B)=1. Any idea how to solve this? It reminds me combinatorial class and generating functions. I would be grateful for any help!

1

There are 1 best solutions below

5
On BEST ANSWER

@user3402584

I am assuming that monets are some kind of currency. The generating function for the number of ways is

$$G(x)=\frac{1}{\left(1-x^A\right) \left(1-x^B\right)}$$

you would check the coefficient of $x^N$

The Frobenius number $(A-1)(B-1)-1$ tells us the highest N that can not be represented by any combination of A and B.