Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int Factorial (int f) {
- int i = 1;
- int ans = 1;
- if ( f >= 0) {
- for (i = 1; i <= f ; i++ ) {
- ans *= i;
- }
- return ans;
- } else {
- return 1;
- }
- }
- int main () {
- int a;
- cin >> a;
- cout << Factorial(a);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement