Prime Factorization List

Prime Factorization List

Medium Computer Mathematics Primes & Factorization 27 views
Explanation Complexity

Problem Statement

Print prime factors with exponents for n.

Input Format

One integer n.

Output Format

Lines: p^e.

Example

360
2^3
3^2
5^1

Constraints

2

Input / Output Format

Input Format
One integer n.
Output Format
Lines: p^e.
Constraints
2

Examples

Input:
360
Output:
2^3 3^2 5^1

Example Solution (Public)

Computer Mathematics
For p from 2..sqrt(n): count exponent while n%p==0. Print if exponent>0. If remaining>1 print remaining^1.

Official Solution Code

For p from 2..sqrt(n): count exponent while n%p==0. Print if exponent>0. If remaining>1 print remaining^1.
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.