Problem:
Prime Factorization

Factorize a given integer n.

Input

n

An integer n is given in a line.

Output

Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a space before each prime factor.

Constraints

2 ≤ n ≤ 109

Sample Input 1

12

Sample Output 1

12: 2 2 3

Sample Input 2

126

Sample Output 2

126: 2 3 3 7

Solution in Python3 (judge verdict: Accepted)

def is_prime(n):
    if n==2:
        return True
    if n%2==0 or n==1:
        return False
    for i in range(3,int(n**0.5)+1,2):
        if n%i==0:
            return False
    return True
        
n = int(input())
print(str(n)+": ", end='')
if is_prime(n):
    print(n)
else:
    ans = []
    while n % 2 == 0:
        n //= 2
        ans.append(2)
    d = 3
    while d <= n ** 0.5:
        if is_prime(d):
            while n % d == 0:
                n //= d
                ans.append(d)
        d += 2
    if is_prime(n):
        ans.append(n)
    print(*ans)