Advertisement
Guest User

Untitled

a guest
Jun 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4. long factorial (long);
  5. int main ()
  6. {
  7. for (int i=1;i<10;i++)
  8. cout<<setw(2)<<i<<"!"<<factorial(i)<<endl;
  9. system ("pause");
  10. return 0;
  11. }
  12. long factorial (long n)
  13. {
  14. if (n<=1)
  15. return 1;
  16. else
  17. return n*factorial (n-1);
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement