Number of digits in N factorial to the power N | CPP program to find count of digits in N factorial raised to N ; we take sum of logarithms as explained in the approach ; multiply the result with n ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int countDigits ( int n ) { double ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) ans += log10 ( i ) ; ans = ans * n ; return 1 + floor ( ans ) ; } int main ( ) { int n = 4 ; cout << countDigits ( n ) << " STRNEWLINE " ; return 0 ; }