1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Recursion Question

Discussion in 'C' started by golf_girl32, Dec 11, 2010.

  1. golf_girl32

    golf_girl32 New Member

    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;
    }
    
     
  2. virxen

    virxen New Member

    can you write a mathematical formula for what you want to calculate?

    maybe this?

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

Share This Page