Count the coins: Difference between revisions

+Maple
No edit summary
(+Maple)
Line 2,123:
CheckThisToo
</lang>
 
=={{header|Maple}}==
 
Straightforward implementation with power series. Not very efficient for large amounts.
 
<lang maple>assume(p::posint,abs(x)<1):
coin:=unapply(sum(x^(p*n),n=0..infinity),p):
ways:=(amount,purse)->coeff(series(mul(coin(k),k in purse),x,amount+1),x,amount):
 
ways(100,[1,5,10,25]);
# 242
 
ways(1000,[1,5,10,25,50,100]);
# 2103596
 
ways(10000,[1,5,10,25,50,100]);
# 139946140451
 
ways(100000,[1,5,10,25,50,100]);
# 13398445413854501</lang>
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
175

edits