Find the total Number of Digits in ( N ! ) N | C ++ program to 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; int CountDigits ( int n ) { if ( n == 1 ) return 1 ; double sum = 0 ; for ( int i = 2 ; i <= n ; ++ i ) { sum += ( double ) log ( i ) / ( double ) log ( 10 ) ; } sum *= ( double ) n ; } int main ( ) { int N = 5 ; cout << CountDigits ( N ) ; return 0 ; }