Given an infinite number of quarters, dimes, nickels and pennies, write code to calculate the number of ways of representing n cents.
Thought:
f(n, number, base) : to represent n cents using number of base.
g(n) = f(n, 0, 25) + f(n, 1, 25) +....
= f(n, 0, 10) + f(n, 1, 10) +... + f(n-25, 0, 10) + f(n-25, 1, 10)+...
No comments:
Post a Comment