Advertisement
HyperSensualNarwhal

Factorial through while

Nov 25th, 2016
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. // factorial through while
  2.  
  3. #include <iostream>
  4.  
  5. using std::cout;
  6. using std::cin;
  7. using std::endl;
  8.  
  9. void main()
  10. {
  11.     setlocale(LC_ALL, "Russian");
  12.  
  13.     int a, i = 0, cntnr;
  14.  
  15.     cout << "Введите значение: "; cin >> a;
  16.  
  17.     cntnr = a - 1;
  18.  
  19.     while (i != cntnr)
  20.     {      
  21.         a *= (++i);
  22.     }
  23.  
  24.     cout << cntnr + 1 << "! = " << a << endl;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement