How to resolve the algorithm Count the coins step by step in the PARI/GP programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Count the coins step by step in the PARI/GP programming language

Table of Contents

Problem Statement

There are four types of common coins in   US   currency:

There are six ways to make change for 15 cents:

How many ways are there to make change for a dollar using these common coins?     (1 dollar = 100 cents).

Less common are dollar coins (100 cents);   and very rare are half dollars (50 cents).   With the addition of these two coins, how many ways are there to make change for $1000? (Note:   the answer is larger than   232).

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Count the coins step by step in the PARI/GP programming language

Source code in the pari/gp programming language

coins(v)=prod(i=1,#v,1/(1-'x^v[i]));
ways(v,n)=polcoeff(coins(v)+O('x^(n+1)),n);
ways([1,5,10,25],100)
ways([1,5,10,25,50,100],100000)

  

You may also check:How to resolve the algorithm Reverse words in a string step by step in the COBOL programming language
You may also check:How to resolve the algorithm Arithmetic/Integer step by step in the 68000 Assembly programming language
You may also check:How to resolve the algorithm Zebra puzzle step by step in the Mathematica/Wolfram Language programming language
You may also check:How to resolve the algorithm Numerical integration step by step in the Pascal programming language
You may also check:How to resolve the algorithm Angle difference between two bearings step by step in the FreeBASIC programming language