PTIME - Prime Time

For your math homework this week your teacher gave you five large numbers and asked you to find their prime factors. However these numbers aren't nearly large enough for someone with knowledge of programming like yourself. So you decide to take the factorial of each of these numbers. Recall that N! (N factorial) is the product of the integers from 1 through N (inclusive). It’s your job now to create a program to help you do your homework.


Each test case contains a number N (2 ≤ N ≤ 10000).


The output should contain a line representing the prime factorization of the factorial given number, which should be of the form: p1^e1 * p2^e2 * ... * pk^ek where p1, p2, ..., pk are the distinct prime factors of the factorial of the given number in increasing order, and e1, e2, ..., ek are their exponents.



2^8 * 3^4 * 5^2 * 7^1

hide comments
AD: 2016-06-14 21:35:46

Easy one ! Simple trial division will do. :D

pranjalikumar9: 2016-05-21 10:40:05

De Polignac's :) learnt something new!

sy_117: 2016-04-05 23:50:26

wow such a nice ques nD i got AC in 0.0 sec !!!!! :P

hanstan: 2016-04-05 19:13:17

Care the limit is for N more than 10000...
Finally AC 0.00s

surya2196: 2016-04-03 22:58:15

lolypop question

rccroshan1: 2016-02-21 09:15:27

The spaces costed me 1 WA.

shubham_garg: 2016-02-20 03:09:18

Nice question for sieve practice.

cqui: 2015-10-24 01:21:27

I had a runtime error (SIGSEGV), I think it ment I was using too much memory, took me a few attempts to realize.

prakash_reddy: 2015-10-19 20:06:12

Nice question.... :)

SangKuan: 2015-08-16 16:22:56

ac with 0.0 sec

Added by:Amlesh Jayakumar
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:DWITE Programming Contest 2012 (Own Problem)