Recursion Problem :-/

Soooo the assignment goes as follows:

Write a C++ program that will output the number of distinct ways in which you can pick k objects out of a set of n objects (both n and k should be positive integers). This number is given by the following formula:
C(n, k) = n!/(k! * (n - k)!)
Your program should use 2 value-returning functions. The first one should be called Factorial and should return n! The second functions should be called Combinations and should return n!/(k! * (n - k)!). Test your program for different values of n and k 5 times (count-controlled loop). Check for errors in input.

so far I have

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace std;
int factorial(int);
int combination(int, int);


void main(void)
{
    int k_obj, n_obj, count; 
    count = 1; 
        while(count <= 5)
        {
            cout << "Please enter in number of k_obj ";
            cin >> k_obj; 
            cout << "Please enter in the number of n_obj ";
            cin >> n_obj;
            count++;
        }

    cout << "The Factorial is " << factorial(n_obj) << " & the combination is " << combination << endl;
    cout << endl; 
}


and I go blank, any one willing to help or direct me to the right source
Factorials are defined as n! = n*(n-1)! with 1! = 1 (or maybe more comprehensible, n! = n * (n-1) * (n-2)... * 1).

Where in particular does your problem lie?
@ccole101187 : your problem was finish !

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
using namespace std;
long long  factorial(int n )
{ 
	if ( n == 0 ) return 1;
	else return (factorial(n-1) *n);
}
	
float    combination(int n , int k )
{
	 float  com_bination =0;
	 com_bination = float (factorial ( n ) / ( factorial (k)*(factorial(n-k))));
	  
      return com_bination;
}

int  main(void)
{
    int k_obj, n_obj, count; 
    count = 1; 
        while(count <= 5)
        {
            cout << "Please enter in number of k_obj ";
            cin >> k_obj; 
            cout << "Please enter in the number of n_obj ";
            cin >> n_obj;
            count++;
    

    cout << "\nThe Factorial is " << factorial(n_obj) << " & the combination is " << combination(n_obj,k_obj) << endl;
}
    cout << endl; 
    system ("pause");
    return 0;
}
Thanx alot @Conan. I appericate it!
Conan, please don't solve homework problems for people. From my experiences it doesn't help as much as a few well-designed hints. :)

-Albatross
Topic archived. No new replies allowed.