fork download
  1. #include<iostream>
  2. #include<math.h>
  3. #include<iomanip>
  4. #include <string>
  5. #include<algorithm>
  6. #include <vector>
  7. using namespace std;
  8.  
  9. long long fact(int m) {
  10. long long factorial = 1;
  11. for (int i = 1;i <= m;i++) {
  12. factorial *= i;
  13. }
  14. return factorial;
  15. }
  16. void fast()
  17. {
  18. ios_base::sync_with_stdio(0);
  19. cin.tie(0);
  20. cout.tie(0);
  21. }
  22.  
  23. int main()
  24. {
  25. fast();
  26.  
  27. int n;
  28. cin >> n;
  29.  
  30. int count = 1;
  31. long long factorial = 1;
  32.  
  33. for (int i = 1;i <= n;i++) {
  34. factorial *= i;
  35.  
  36. while (factorial >= 10) {
  37. count++;
  38. factorial /= 10;
  39. }
  40. }
  41. cout << "Number of digits of " << n << "! is " << count;
  42.  
  43. return 0;
  44. }
  45.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Number of digits of 21944! is 82910