3 # This file is part of NIT ( http://www.nitlanguage.org ).
4 # This program is public domain
6 # Task: Count_the_coins
7 # SEE: <http://rosettacode.org/wiki/Count_the_coins>
10 fun changes
(amount
: Int, coins
: Array[Int]): Int
12 var cache
= new Array[Int].filled_with
(0, amount
+1)
15 for j
in [coin
..amount
] do
16 cache
[j
] += cache
[j
- coin
]
22 print changes
(100, [1, 5, 10, 25])
23 print changes
(100000, [1, 5, 10, 25, 50, 100])