Find the total Number of Digits in ( N ! ) N | Function to find the total Number of Digits in ( N ! ) ^ N ; Finding X ; Calculating N * X ; Floor ( N * X ) + 1 return ceil ( $sum ) ; equivalent to floor ( sum ) + 1 ; Driver code
< ? php function CountDigits ( $ n ) { if ( $ n == 1 ) return 1 ; $ sum = 0 ; for ( $ i = 2 ; $ i <= $ n ; ++ $ i ) { $ sum += log ( $ i ) / log ( 10 ) ; } $ sum *= $ n ; } $ N = 5 ; echo CountDigits ( $ N ) ; ? >