LENGFACT - Factorial length

no tags 

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

hide comments
kass_97: 2016-12-31 23:15:05

Simply formula based, AC in 0.02

umohan: 2016-12-08 22:33:43

consider 0

sandeep_4141: 2016-10-22 09:16:28

i use kamenertsky ...my code give correct ans to all testcase of spoj toolkit on ideone but i get WA on spoj.need help??

square1001: 2016-08-02 04:42:49

Pay attention for test case which n is equal to 0.

akshayjhamb2: 2016-06-13 13:02:00

easy problem , u just need to know kamenetsky's formula

nonushikhar: 2016-03-11 21:25:07

worst qs shud be removed
formulae based and causes confusion btw log10 and log

ghost_wire: 2016-02-09 19:07:15

easy one with kamenetsky algo.

Divyansh Shukla: 2015-12-04 14:06:30

Kamenetsky's formula is not valid for every n. It has a counterexample at 6561101970383.

dwij28: 2015-08-29 22:23:03

Questions like these should be moved to tutorials imho because these are completely formula based. By the way, the formula is badass.. Hats Off to Kamenetsky :)

anuveshkothari: 2015-08-09 21:24:23

formula based question


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

Problem's scores 1 vote

Concept difficulty
Concept difficulty 35%
Implementation difficulty
Implementation difficulty 10%
26 15