Advertisement
TheMagnusRex

pavlova4.1

Jan 13th, 2021
670
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.22 KB | None | 0 0
  1. using namespace std;
  2.  
  3. #include <iostream>
  4.  
  5. double fact(int x){
  6.     if (x>1){
  7.         return x*fact(x-1);
  8.     }
  9.     else{
  10.         return 1.0;
  11.     }
  12. }
  13.  
  14. int main(){
  15.     int a;
  16.     cout<<"input:";
  17.     cin>>a;
  18.     cout<<a<<"!="<<fact(a);
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement