login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A260688 a(n) = the least number of pieces of currency of denominations .01, .05, .10, .25, 1, 5, 10, 20, 50, 100 that the greedy algorithm uses to make n times .01 (n "cents") in change. 0

%I #24 Apr 24 2016 23:23:00

%S 0,1,2,3,4,1,2,3,4,5,1,2,3,4,5,2,3,4,5,6,2,3,4,5,6,1,2,3,4,5,2,3,4,5,

%T 6,2,3,4,5,6,3,4,5,6,7,3,4,5,6,7,2,3,4,5,6,3,4,5,6,7,3,4,5,6,7,4,5,6,

%U 7,8,4,5,6,7,8,3,4,5,6,7,4,5,6,7,8,4,5,6,7,8,5,6,7,8,9,5,6,7,8,9

%N a(n) = the least number of pieces of currency of denominations .01, .05, .10, .25, 1, 5, 10, 20, 50, 100 that the greedy algorithm uses to make n times .01 (n "cents") in change.

%H US Treasury, <a href="https://www.treasury.gov/resource-center/faqs/Coins/Pages/denominations.aspx">Denominations of Coins</a>

%H US Treasury, <a href="https://www.treasury.gov/resource-center/faqs/Currency/Pages/denominations.aspx">Denominations of Paper Currency</a>

%o (Python)

%o def how_many(cents):

%o #d = denominations

%o d = ['$0.01', '$0.05', '$0.10', '$0.25',

%o '$1', '$5', '$10', '$20', '$50', '$100']

%o coins = {coin: 100*float(str(coin)[1:]) for coin in d}

%o how_many = {d[i]: 0 for i in range(10)}

%o while len(d) != 0:

%o how_many[d[-1]] = cents // coins[d[-1]]

%o cents %= coins[d[-1]]

%o d.pop()

%o return int(sum(how_many.values()))

%Y Cf. A067997, A080897, A108536.

%K nonn

%O 0,3

%A _Edward Minnix III_, Nov 15 2015

%E Edited by _N. J. A. Sloane_, Apr 24 2016

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 29 06:34 EDT 2024. Contains 371265 sequences. (Running on oeis4.)