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

hide comments
upstriver: 2021-09-03 09:19:56

AC in 1 Go.....................................................

elmer_fudd: 2019-01-03 22:13:45

AC in 1 go <3

ameyanator: 2018-09-25 15:03:40

well sieve makes things easier :)

indotech: 2018-01-27 23:48:33

good problem to learn

vishwanath_26: 2017-10-12 14:23:45

Take care of output format......
And get AC!!!

stranger77: 2017-02-07 10:56:49

Easy one AC in 1 go......0.0sec!

aeonflux: 2016-12-11 16:39:17

no need of sieve..simple brute force works!!!!

Anuj Arora: 2016-09-03 21:26:30

AC in one go!!! 111th question

Last edit: 2016-09-03 21:27:14
vinay12345: 2016-08-25 17:37:30

AC in one go ...0.00sec

mkfeuhrer: 2016-06-14 23:33:55

AC in 1 go :-) my 100th :-) prime funn..!


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)