fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. ll factorial(ll n) {
  5. if (n <= 1) {
  6. return 1;
  7. }
  8. ll result = 1;
  9. for (ll i = 1; i <= n; i++) {
  10. result *= i;
  11. }
  12. return result;
  13. }
  14.  
  15. ll digitcount(ll n) {
  16. if (n <= 1) {
  17. return 1;
  18. }
  19. ll temp = n/10;
  20. return digitcount(temp)+1;
  21. }
  22.  
  23. int main() {
  24. int R;
  25. cin>>R;
  26. ll n = factorial(R);
  27. n= digitcount(n);
  28. cout<<"Number of digits of "+to_string(R)+"! is "+to_string(n)<<endl;
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0s 5276KB
stdin
Standard input is empty
stdout
Number of digits of 5448! is 2