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.

Input

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

Output

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.

Example

Input:
10

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

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

hide comments
2016-06-14 21:35:46 AD
Easy one ! Simple trial division will do. :D
2016-05-21 10:40:05
De Polignac's :) learnt something new!
2016-04-05 23:50:26
wow such a nice ques nD i got AC in 0.0 sec !!!!! :P
2016-04-05 19:13:17 hanstan
Care the limit is for N more than 10000...
Finally AC 0.00s
2016-04-03 22:58:15
lolypop question
2016-02-21 09:15:27 rccroshan1
The spaces costed me 1 WA.
2016-02-20 03:09:18
Nice question for sieve practice.
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.
2015-10-19 20:06:12
Nice question.... :)
2015-08-16 16:22:56 SangKuan
ac with 0.0 sec
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.