// // lotto1.cpp // CSC 215 // John Rogers // // This program computes the odds of winning the lottery. // #include long factorial(long n); int main() { long numberOfBalls; long numberChosen; long odds; cout << "How many balls are in the game? "; cin >> numberOfBalls; cout << "How many balls are chosen from that? "; cin >> numberChosen; odds = factorial(numberOfBalls) / (factorial(numberOfBalls - numberChosen) * factorial(numberChosen)); cout << "The odds of winning are " << odds << ":1." << endl; return 0; } // // This computes factorial iteratively. // long factorial(long n) { long index; long answer; answer = 1; for (index = 1; index <= n; index++) { answer = answer * index; } return answer; }