Submit  All submissions  Best solutions  Back to list 
FACTLENG  Factorial length 
Wersja polska  English version 
Given integer n, print length of n! (which is factorial of n).
Input
The first line of the standard input contains one integer t (t<10001) which is the number of test cases.
In each of the next t lines there is number n (0<=n<=5*10^9).
Output
For each test, print the length of n!.
Example
Input: 3
1
10
100
Output: 1
7
158
Added by:  Piotr Kąkol 
Date:  20091226 
Time limit:  4.855s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS OBJC SCM qobi VB.NET 
hide comments


20130828 07:56:05 Dominique VAILLANT
@Mitch: And now 52 in awk, absolute record! Rude awakening for me... 

20130827 13:19:58 Dominique VAILLANT
Wow! 86 in C. Hat's off to Grand Master Mitch! 

20130818 07:35:50 Raushan Kumar
simple formulae to get number of digits search it up 

20120128 17:18:12 Piotr KÄ…kol
@saurabh jain  Your PI value is not precise enough. 

20120124 18:22:50 Saurabh Jain
i dont know why it is showing WA for my code even after my answer matches with the highest value of n!! can u tell me the reason ? 

20110508 11:26:20 challenger
@HWK  Even if You just reached (not beat) "my" solution I could always disqualify it so that You would be the rightful leader of C in this task. ;) 

20110507 20:29:26 HWK
@challenger: It's painful that you've pushed my "nice" Csolution to the second page of best solutions. :) Edit: Back again! Last edit: 20110508 08:39:09 

20101227 23:58:35 Marty OBrien
Thanks Piotr. That solution was OK when perl is built with 64bit integers, but not with 32bit. 

20101223 13:27:45 Piotr KÄ…kol
Yes, for 0! You should print 1. Your mistake is that for bigger numbers You always print 1. Before submitting always check the hardest case. Here for 5*10^{9} You should print 46323377618. 

20101222 20:10:04 Marty OBrien
Having trouble getting the right answer to this one. The length of 0! is 1, right? 