File Exchange

## Represented a positive integer number as a sum of multiple positive integer numbers.

version 1.0.0.0 (1.43 KB) by Pramit Biswas

### Pramit Biswas (view profile)

A positive integer number N is represented as a sum of K positive integer numbers.

Updated 12 Jan 2017

A positive integer number N can be represented as a
sum of K positive integer numbers.
i.e, N = n1 + n2 + ... + nk
E.g. 1: 6(N) can be represented as a sum of 2(K) numbers in following way: (1+5), (2+4), (3+3).
E.g. 2: 8(N) can be represented as a sum of 3(K) numbers in following way: (1+1+6), (1+2+5), (1+3+4), (2+2+4), (2+3+3).
To run this function, sample input:
N_as_sum_of_K_numbers(8,3)
Points to remember:
1. N, K both should be positive integer
2. do not give more than two inputs, it will give wrong or no result

### Cite As

Pramit Biswas (2020). Represented a positive integer number as a sum of multiple positive integer numbers. (https://www.mathworks.com/matlabcentral/fileexchange/61122-represented-a-positive-integer-number-as-a-sum-of-multiple-positive-integer-numbers), MATLAB Central File Exchange. Retrieved .

balor bhaiti

Pramit Biswas

### Pramit Biswas (view profile)

@Stephen Cobeldick, Thanks for the information, partitions tag added. Didn't checked those functions. I'm playing with the problem mentioned in the title and description and uploaded it after coding.

Stephen Cobeldick

### Stephen Cobeldick (view profile)

The author does not mention anywhere that this function calculates partitions: "a partition of a positive integer n, also called an integer partition, is a way of writing n as a sum of positive integers"

Not mentioning "partition" anywhere is like writing a Sine function and describing it as "a repeating smooth curve closely related to circle geometry", but not actually writing "sine" anywhere.

Once we realize that this submission calculates partitions, then we also realize that there are many submissions already on FEX that provide this functionality (and more):

And related ones like this:

It is not clear what advantages this new submission has over the existing partition tools.

##### MATLAB Release Compatibility
Created with R2007a
Compatible with any release
##### Platform Compatibility
Windows macOS Linux