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

A positive integer number N is represented as a sum of K positive integer numbers.
35 Downloads
Updated 12 Jan 2017

View License

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 (2024). 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 .

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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0