Count the coins: Difference between revisions
Content added Content deleted
(Added Wren) |
No edit summary |
||
Line 1,727: | Line 1,727: | ||
Value of 100 can be changed by using a set of 1 5 10 25 coins in 242 different ways. |
Value of 100 can be changed by using a set of 1 5 10 25 coins in 242 different ways. |
||
</pre> |
</pre> |
||
=={{header|IS-BASIC}}== |
|||
<lang IS-BASIC>100 PROGRAM "Coins.bas" |
|||
110 LET MONEY=100 |
|||
120 LET COUNT=0 |
|||
125 PRINT "Count Pennies Nickles Dimes Quaters" |
|||
130 FOR QC=0 TO INT(MONEY/25) |
|||
150 FOR DC=0 TO INT((MONEY-QC*25)/10) |
|||
170 FOR NC=0 TO INT((MONEY-DC*10)/5) |
|||
190 FOR PC=0 TO MONEY-NC*5 STEP 5 |
|||
200 LET S=PC+NC*5+DC*10+QC*25 |
|||
210 IF S=MONEY THEN |
|||
220 LET COUNT=COUNT+1 |
|||
230 PRINT COUNT,PC,NC,DC,QC |
|||
240 END IF |
|||
250 NEXT |
|||
260 NEXT |
|||
270 NEXT |
|||
280 NEXT |
|||
290 PRINT COUNT;"different combinations found."</lang> |
|||
=={{header|J}}== |
=={{header|J}}== |