How to do this Question ?
My Code takes 8.22 seconds !
But the time limit is 1 sec .
Thanks in advance !
How to do this Question ?
My Code takes 8.22 seconds !
But the time limit is 1 sec .
Thanks in advance !
Use Seive to find all the prime numbers upto 100000.
For each prime p , the power of p in n! is given by :
power§ = n/p + n/p^2 + n/p^3 …until we get a zero
Our ans is for each prime p :
(power(p1)+1) * (power(p2)+1) * … (power(pk)+1) , assuming there are k prime numbers less than 100000
Code : http://ideone.com/eyT4zx
Can you tell me how did you deduce points 2 and 3.