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 C# (judge verdict: Accepted)

using static System.Math;using static System.Console;using System.Collections.Generic;using System.Linq;using System;using System.Collections;

class Program
{
    #region Reader
    static string ReadStr => Console.ReadLine();
    static string[] ReadStrs => Console.ReadLine().Split(' ');
    static int ReadInt => Convert.ToInt32(Console.ReadLine());
    static int[] ReadInts => Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
    static long ReadLong => Convert.ToInt64(Console.ReadLine());
    static long[] ReadLongs => Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
    #endregion
    #region Method
    static int mod = (int)Pow(10, 9) + 7;
    public static int Mod(int a,int mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    public static long Mod(long a, int mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    #endregion

    public static Dictionary<int, int> PrimeFactors(int n)
    {
        int i = 2;
        int tmp = n;
        Dictionary<int, int> d = new Dictionary<int, int>();

        while (i * i <= n) //※1
        {
            if (tmp % i == 0)
            {
                tmp /= i;
                if (d.ContainsKey(i)) d[i]++;
                else d.Add(i, 1);
            }
            else
            {
                i++;
            }
        }
        if (tmp != 1)
        {
            if (d.ContainsKey(tmp)) d[tmp]++;
            else d.Add(tmp, 1);
        }
        return d;
    }


    static void Main()
    {
        int N = ReadInt;

        var d = PrimeFactors(N);

        List<int> ans = new List<int>();
        Write(N + ": ");

        foreach (var item in d)
        {
            for (int i = 0; i < item.Value; i++)
            {
                ans.Add(item.Key);
            }
        }
        WriteLine(string.Join(" ", ans));
    }



}