Advertisement
stevomitric

inverse factorial

Nov 5th, 2018
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. string s;
  7.  
  8. int main() {
  9.     cin >> s;
  10.  
  11.     if (s == "1") cout << 1 << endl;
  12.     else if (s == "2") cout << 2 << endl;
  13.     else if (s == "6") cout << 3 << endl;
  14.     else if (s == "24") cout << 4 << endl;
  15.     else if (s == "120") cout << 5 << endl;
  16.     else if (s == "720") cout << 6 << endl;
  17.     else {
  18.         double resoult = 0;
  19.         for (int i = 1; i < 1000000; ++i) {
  20.             resoult += log10(i);
  21.             if ( (int)resoult + 1 == s.size() ) {
  22.                 cout << i << endl;
  23.                 break;
  24.             }
  25.         }
  26.     }
  27.  
  28.  
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement