diff --git a/find factorial.cpp b/find factorial.cpp new file mode 100644 index 0000000..60f1e3b --- /dev/null +++ b/find factorial.cpp @@ -0,0 +1,21 @@ +#include +using namespace std; + +int main() { + int n; + long double factorial = 1.0; + + cout << "Enter a positive integer: "; + cin >> n; + + if (n < 0) + cout << "Error! Factorial of a negative number doesn't exist."; + else { + for(int i = 1; i <= n; ++i) { + factorial *= i; + } + cout << "Factorial of " << n << " = " << factorial; + } + + return 0; +}