Advertisement
informaticage

N fattoriale

Sep 18th, 2014
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int fattoriale (int n)
  7. {  
  8.     if (n <= 1)
  9.         return 1;
  10.     else
  11.         return n * fattoriale(n - 1);
  12. }
  13.  
  14. int main(int argc, char *argv[])
  15. {
  16.     int fatt;
  17.     cout << "inserire fatt : " << endl;
  18.     cin >>  fatt;
  19.     cout << fattoriale(fatt) << endl;
  20.     system("pause >null");
  21.     return EXIT_SUCCESS;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement