The number of ways you could pay 1997 using decimal currency of $1$,$10$,$100$,$1000$ . 
The way I did it is as follows:
To pay $1997$, one could pay :$1900$, $90$ and $7$. 
There is only one way to pay $7$, using notes of value of $1$. 
There are $10$ ways of paying $90$, using $1$ or $10$ notes.
Now, to work out how many ways we could pay 1900 using $1000$, $100$, $10$ and $1$:
Suppose we pay $1900$ using $n$ $1000$ notes, $m$ $100$ notes, $r$ $10$ notes and $k$ $1$ notes. 
So, we write:
$$1000n + 100m + 10r + k = 1900$$
$n$ could take any value between $0$ and $1$
$m$ could take any value between $0$ and $19-10n$
$r$ could take any value between $0$ and $190 - 100n - 10m$ at 
Once the value of $r$ is decided, then the value of $k$ is automatically decided. 
Then the Total number of ways of paying $1900$ is:
$$\sum_{n=0}^{n=1}\sum_{m=0}^{m = 19-10n}(191 - 100n - 10m)$$
Which simplifies to:
$$\sum_{n=0}^{n=1}(1920 - 1960n + 500n^2)$$
Leading to:
$$2380$$
So in total, we've got $1$ way to pay $7$, $10$ ways to pay $90$ and $2380$ to pay $1900$. 
So, the total number of ways is $$2380*10*1 = 23800$$
Is is this the right approach? 
Thanks, 
 A: This appears to be a problem from the 1997 British Mathematical Olympiad (https://bmos.ukmt.org.uk/home/bmo1-1997.pdf) - as such it seems reasonable to not use generating functions (as Jack D'Aurizio has in his comment), and to come up with a solution that requires only hand computation.  So let's try to adapt your approach.
In a solution to $1000n + 100m + 10r + k = 1997$ in positive integers:


*

*$n$ is 0 or 1

*$m$ is between $0$ and $19 - 10n$ 

*$r$ is between $0$ and $199 - 100n - 10m$ (so there are $200 - 100n - 10m$ possible values).   This is the error in your original solution - once $n$ and $m$ are determined we haver $1000n + 100m$ pippins, so the amount remaining to be allocated is $(1997 - 1000n - 100m)/10$.

*$k$ is fixed once $n, m, r$ are determined. 


So you are looking for
$$\sum_{n=0}^1 \sum_{m=0}^{19 - 10n} (200 - 100n - 10m) $$
and notice that this differs from your double sum only by replacing $191$ with $200$.  Now it's just computation.
Explicitly expanding the outer sum into the $n = 0$ and $n = 1$ terms gives
$$ \sum_{m=0}^{19} (200 - 10m) + \sum_{m=0}^{9} (100-10m) $$.
By the usual formulas for the sum of arithmetic progressions, this is
$$ {20 \over 2} (10+200) + {10 \over 2} (10+100) = (10)(210) + (5)(110) = 2100 + 550 = 2650. $$
