Counting number of sums of a numer without permutations

  c++, recursion
/*
* You must find recursively the number of ways that a given integer can be expressed as the sum 
* of the unique, natural numbers. 
* 
* Example: the number of ways to get the number 6 by combining unique natural numbers is 4.
* 1) 1 + 5 = 6
* 2) 2 + 4 = 6
* 3) 6 = 6
* 4) 1 + 2 + 3 = 6
*/

static int powerSum(int n) {
    return 0; 
}

I’m currently solving the following and all the solutions I’ve tried are wrong as I can’t get it to work without permutations. Any help?

Source: Windows Questions C++

LEAVE A COMMENT