however, it runs.. and my factorial function works.. however, my permutation is not giving the correct output.. could somone please help me with this?
int factorial (unsigned long);
int permutation (unsigned long, unsigned long);
#include <iostream>
using namespace std;
int main()
{
unsigned long n,r = 0;
cout << "please enter n value " << endl;
cin >> n;
cout << "please enter r value " << endl;
cin >> r;
cout << "P(" << n << "," << r << ") is equal to.." <<
cout << permutation(n, r);
return 0;
}
int factorial(unsigned long number)
{
int temp;
if(number <= 1) return 1;
temp = number * factorial(number - 1);
return temp;
}
int permutation( unsigned long k, unsigned long r)
{
int result = 0;
int temp = k - r;
result = factorial(k)/factorial(temp);
return result;
}
Edited by WingedPanther, 18 April 2008 - 07:58 AM.
add code blocks


Sign In
Create Account

Back to top









