MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Using only pennies (1), nickels (5), dimes (10), quarters (25), half dollars (50), and dollars (100), how many different combinations can be made from a given amount in cents.

Example 1:

>>change(17)

%Output will be the the number of combinations of coins to make 17 cents.

c =

6

There are 6 combinations:

17 pennies

12 pennies and 1 nickel

7 pennies and 2 nickels

2 pennies and 3 nickels

7 pennies and 1 dime

2 pennies, 1 nickel, and 1 dime.

Example 2:

>>change(100)

c =

293

45 correct solutions
19 incorrect solutions

Last solution submitted on Mar 11, 2015

2 players like this problem

2 Comments

Alfonso Nieto-Castanon
on 7 Feb 2013

and while we are at it...

Khaled Hamed
on 7 Feb 2013

well, ...

1 Comment

Alfonso Nieto-Castanon
on 7 Feb 2013

less 'redundant', more 'shorter' :)

1 player likes this solution

1 Comment

Khaled Hamed
on 6 Feb 2013

Redundant, but shorter.

2 players like this solution

1 Comment

Khaled Hamed
on 6 Feb 2013

We are getting there... :)

1 player likes this solution

1 Comment

Alfonso Nieto-Castanon
on 6 Feb 2013

nice, I did not know about combvec; those ever useful nnet functions :)

1 Comment