Recursion Question

Go4Expert Member
11Dec2010,05:41   #1
golf_girl32's Avatar
How do I write a recursive function that counts the number of sequences that sum up to that number that the user inputs? I have most of the program but I'm not sure how to make the loop work.

Code:
#include <iostream>

using namespace std;

int partition(int n, int max)
{
  if(n==0)
    return(0);
  int ret = 0;
  if(n<=max)
    ret=1;
  for()
  {

  }
  return(ret);
}

int main()
{
    cout << "Enter a number: "  << endl;
    cin >> n >> endl;
    return 0;
}
Pro contributor
11Dec2010,06:02   #2
virxen's Avatar
can you write a mathematical formula for what you want to calculate?

maybe this?

sum=1+2+3+5+.....+n
shabbir like this