LENGFACT - Factorial length

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! (which is factorial of n).

Example

Input:
3
1
10
100

Output:
1
7
158

Added by:Piotr Kąkol
Date:2010-01-19
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:Copy of the problem: FACTLENG with different assessment

hide comments
2020-04-21 14:32:27
Sorry if you're not bright enough like Dmitri Kamenetsky. Good for you, he already developed a formula and published it. Why don't you go check it out?
2019-01-17 11:22:46
Google Kamenetsky's formula
2018-10-16 12:27:05
use Kamenetsky’s formula .
2018-09-25 14:52:00
How in the name of hamburgers is someone supposed to come up with this on his own????!
2018-01-07 15:03:55
in c, use PI=acos(-1); under math.h :-)
2017-12-20 14:34:54
define a variable called pi upto as many digits as possible and then do it. Good formula based problem.
2017-06-07 21:09:01 prabodh prakash
In Python, I used 22/7 for pi and was getting WA. then I used math.pi and got Accepted.
2017-05-31 13:29:00
i am getting wrong answer even after getting right answer on ideone for of the cases and i have kamenetskys formula only


Last edit: 2017-05-31 13:29:39
2017-04-11 12:34:34
Keep 0 in mind
2017-03-13 17:32:21
use long long for input type of n, costed few WA!
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.