Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int Factorial (int f) {
  6. int i = 1;
  7. int ans = 1;
  8. if ( f >= 0) {
  9. for (i = 1; i <= f ; i++ ) {
  10. ans *= i;
  11. }
  12. return ans;
  13. } else {
  14. return 1;
  15. }
  16. }
  17.  
  18. int main () {
  19. int a;
  20. cin >> a;
  21. cout << Factorial(a);
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement