Advertisement
Raqeeb_Alnakib

Best factorial calculator in C++

Nov 2nd, 2019
6,118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. /*
  2.  
  3. Please, Don't Miss Visit My Site:
  4.  
  5.  
  6. https://global-prog.com
  7.  
  8.  
  9. */
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20. #include <iostream>
  21. #include <math.h>
  22. #include <corecrt_math_defines.h>
  23. using namespace std;
  24.  
  25. int f = 1;
  26.  
  27. int x,y;
  28.  
  29. int main()
  30. {
  31.     cout << "Enter your number to get \"!\" : ";
  32.     cin >> x;
  33.     y = x;
  34.  
  35.     while (x != 0) {
  36.         f *= x--;
  37.     }
  38.  
  39.     cout << "Factorial of " << y << " is = " << f << endl;
  40.  
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement