/* For example, 1000 factorial digits:
Log10 (1) + log10 (2) + · + log10 (1000) rounded up and added 1
*/
# Include <stdio. h>
# Include <math. h>
Int Main ()
{
Int N, I, T;
Double D;
Scanf ( " % D " , & T );
While (T --)
{
While (Scanf ( " % D " , & N ))
{
D = 0 ;
For (I = 1 ; I <= N; I ++)
D + = log10 (I );
Printf ( " % D \ n " ,( Int ) D + 1 );
}
}
Return 0 ;
}
/*
Or
# Include <stdio. h>
# Include <math. h>
# Define PI 3.14159265
Int main ()
{
Int Len, N;
While (scanf ("% d", & N )! = EOF)
{
If (n = 1)
Len = 1;
Else
Len = (INT) Ceil (n * log (N)-N + Log (2 * n * PI)/2)/log (10 )); /// calculate the upper bound of Ceil, that is, the minimum integer not smaller than a value.
// String formula lnn! = Nlnn-N + 0.5 * ln (2 * n * PI)
// While the number of digits of the n factorial is equal:
// Log10 (N !) Add 1 after rounding
// Log10 (N !) = Lnn! /Ln (10)
// Ceil is the upper bound, that is, the smallest integer of N.
// Log is the natural logarithm.
Printf ("% d \ n", Len );
}
Return 0;
}