Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. // helloworld.cpp
  2.  
  3. #include <iostream>
  4.  
  5. int faculty(int n ){
  6.     if(n > 0)
  7.         return n * faculty(n-1);
  8.     else
  9.         return 1;
  10. }
  11.  
  12. int main(){
  13.     int n, f;
  14.     std::cout << "Calculate faculty of: ";
  15.  
  16.     std::cin >> n;
  17.  
  18.     f = faculty(n);
  19.  
  20.     std::cout << f;
  21.  
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement