vlatkovski

Factorial finder

Jul 25th, 2016
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.21 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int factorial(int x) {
  5.     if (x == 1) {
  6.         return 1;
  7.     } else {
  8.         return x*factorial(x-1);
  9.     }
  10. }
  11.  
  12. int main() {
  13.     cout << factorial(3);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment