A358012 Minimal number of coins needed to pay n cents using coins of denominations 1 and 5 cents.
0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8, 5, 6, 7, 8, 9, 6, 7, 8, 9, 10, 7, 8, 9, 10, 11, 8, 9, 10, 11, 12, 9, 10, 11, 12, 13, 10, 11, 12, 13, 14, 11, 12, 13, 14, 15, 12, 13, 14, 15, 16, 13, 14, 15, 16, 17, 14, 15, 16, 17, 18, 15, 16
Offset: 0
Links
Programs
-
Mathematica
Array[Total@ QuotientRemainder[#, 5] &, 77, 0] (* Michael De Vlieger, Nov 03 2022 *)
-
PARI
a(n) = n\5 + n%5 \\ Thomas Scheuerle, Oct 24 2022
-
PARI
a(n) = vecsum(divrem(n, 5)); \\ Michel Marcus, Nov 03 2022
-
Python
def a(n): return n//5 + n%5 # Michael S. Branicky, Nov 03 2022
Comments