I'm doing a little bit of homework, and one of my problems is as follows:

Write a function that will return N! when N is passed to it.

Your program should ask for N and K. The probability of K numbers being selected from N numbers is:

Basically, it's a lottery program, where the user enters the number of chances he's purchases, and enters the number of chances total. The program computes the probability. I know that my factorial function that I created is not the problem, it has to be somewhere in the code itself. Any help is appreciated, here's the code:Code:N! Probability = -------- K!(N-K)!

Thanks!Code:#include <iostream> using namespace std; int fac(int n); int main() { int fact1, fact2, picks, total, fact3, subtraction; float output; cout << "Enter the amount of chances you are choosing..." << '\n' << endl; cin >> picks; cout << '\n' << "Now, enter the total number of choices..." << '\n' << endl; cin >> total; subtraction = total - picks; output = fac(total) / (fac(total * fac(subtraction))); cout << '\n' << "Your chances are 1 in " << output << "." << endl; return (0); } int fac(int n) { int i=0, fact=1; for(i=1;i<=n;++i) { fact=fact*i; } return(fact); }