Count the coins: Difference between revisions
m
→{{header|EasyLang}}
Line 1,202:
len cache[] 100000 * 7 + 6
val[] = [ 1 5 10 25 50 100 ]
if sum = 0
.
if sum < 0 or kind = 0
.
chind = sum * 7 + kind
if cache[chind] > 0
.
r2 = count (sum - val[kind]) kind
r1 = count sum (kind - 1
r = r1 + r2
cache[chind] = r
return r
.
print count 100 4
print
print count
# this is not exact, since numbers
# are doubles and r > 2^53
</syntaxhighlight>
|