Different ways to generate a big number with some small numbers Imagine we have a set of numbers $\{x_1,x_2,\dots,x_m\}$. We want to compute the different ways to make a big number $P$ by those small numbers.

For example, if $P = 5$ and we have $\{1,2,3,4,5\}$ we can make $P$ by:


1+1+1+1+1 or 
2+3 or
1+4 or ...
This is a well-known problem called the subset sum problem. Essentially we are looking for a subset of the elements that sums up to a target value, P. The problem is NP-hard, meaning it does not admit a polynomial time solution unless P = NP.  Here is a link that explains how to solve this problem. There are multiple algorithms for the problem. The recursive one runs at in an exponential time of $O(2^n)$. This problem is mostly associated with a Dynamic Programming solution since its run-time is $O(P\cdot n)$, such a running time is called pseudo polynomial, since it is polynomial in the value of the input instead of its size (which is the log of the value).