Problem 1873. Break it up! Break it up!
You have N pennies. Write a Matlab script that will reveal how many different ways you can break up those pennies. For example, with 5 pennies, there are seven different ways you can divide them:
- (1,1,1,1,1)
- (2,1,1,1)
- (2,2,1)
- (3,2)
- (3,1,1)
- (4,1)
- (5)
The order of the coins does not matter, so (2,2,1) is considered the same combination as (2,1,2). You can assume that N will always be a positive integer.
Solution Stats
Problem Comments
-
4 Comments
Show
1 older comment
James
on 18 Sep 2013
Changed to p(299), which is <2^53. Thanks for the heads up.
James
on 18 Sep 2013
Interestingly, p(299) had some issues as well. Changed again to p(199), which seems to be working OK.
ChrisR
on 23 Apr 2022
If I ever want to learn something, I dial up a problem from James.
Solution Comments
Show commentsGroup

Board Games II
- 14 Problems
- 10 Finishers
- High Precision Square Root (Inspired by Project Euler 80)
- Damping of Servomotors with Tachometer Feedback
- Find the right number make the equation
- Deriving a function using the difference quotient
- Fast 1-D Convolution (full shape)
- Fast 1-D Convolution (same shape)
- Fast 1-D Convolution (valid shape)
- Lambert's W
- First use of arrayfun() and anonymous function @(x)
- Cell Operator *
- Product of two multivariate polynomials
- Multivariate polynomials - convert monomial form to array
- Multivariate polynomials - overload multiplication
- Multivariate polynomials - emulate symbolic form
- Rewrite setdiff to account for non-unique values
Problem Recent Solvers57
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!