This program calculates the factorial of a given positive integer.
#include <iostream>
int main() {
int n;
std::cout << "Enter a positive integer: ";
std::cin >> n;
unsigned long long factorial = 1;
for(int i = 1; i <= n; ++i) {
factorial *= i;
}
std::cout << "Factorial of " << n << " = " << factorial << std::endl;
return 0;
}
No comments:
Post a Comment