Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Recursion Question (http://www.go4expert.com/forums/recursion-question-t24146/)

golf_girl32 11Dec2010 05:41

Recursion Question
 
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;
}


virxen 11Dec2010 06:02

Re: Recursion Question
 
can you write a mathematical formula for what you want to calculate?

maybe this?

sum=1+2+3+5+.....+n


All times are GMT +5.5. The time now is 02:32.