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 ≤ 10 9   Sample Input 1 12 Sample Output 1 12: 2 2 3 Sample Input 2 126 Sample Output 2 126: 2 3 3 7

Solution (Python):
import math

def Eratos(n):
	if n==2:
		return [2]
	primes = [2]
	num = [2*i+1 for i in range(1,n//2)]
	tmp = []
	top = 1
	while top < math.sqrt(n) and math.sqrt(n)>=2:
		top = num[0]
		for i in range(1,len(num)):
			if num[i] % top != 0:
				tmp.append(num[i])
		num = tmp
		tmp = []
		primes.append(top)
	for i in range(len(num)):
		primes.append(num[i])
	return primes

n=int(input())
test=n
p=Eratos(math.ceil(math.sqrt(test)))
fac=[]
next_flag=True
while test!=1 and len(p)!=0:
	if next_flag:
		ch=p.pop(0)
		next_flag=False
	if test%ch==0:
		while test%ch==0:
			fac.append(ch)
			test//=ch
	next_flag=True
if test!=1:
	fac.append(test)
print("%d: " % n,end='')
for i in range(len(fac)):
	if i!=len(fac)-1:
		print(fac[i],end=' ')
	else:
		print(fac[i])

Solution (Python):
n = int(input())
num = n

fct = []
b = 2
while b * b <= n:
    while n % b == 0:
        n //= b
        fct.append(b)
    b += 1
if n > 1:
    fct.append(n)

print(str(num) + ": " + ' '.join(str(f) for f in fct))

Solution (Python):
n=int(input())
n2=str(n)
def factorint(N):
    i=2
    fct=[]
    while i**2<=N:
        if N%i!=0:
            i+=1
        else:
            N//=i
            fct.append(i)
    if N>1:
        fct.append(N)
    return fct

print(n2+":"," ".join(map(str,factorint(n))))

Solution (Python):
import math
from typing import List


def calc_divisors(n):
    divisors = [1, n]

    for i in range(2, int(math.sqrt(n))+1):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n // i)

    return sorted(divisors)


def prime_factorize(n: int) ->List[int]:
    prime_factors = []
    divisors = calc_divisors(n)[1:]

    for i in divisors:
        while True:
            div, mod = divmod(n, i)
            if mod == 0:
                prime_factors.append(i)
                n = div
            else:
                break
        if n == 1:
            break
    return prime_factors


def main():
    n = int(input())
    prime_factors = prime_factorize(n)
    print("{}: {}".format(n, ' '.join(map(str, prime_factors))))


main()

Solution (Python):

"""
Created on Fri Nov 16 23:01:57 2018

@author: maezawa
"""

n = int(input())
sqn = int(n**0.5)+1

is_prime = [True]*(sqn+1)

is_prime[0] = False
is_prime[1] = False

for i in range(2, sqn//2):
    if is_prime[i] == True:
        for j in range(2*i,sqn+1,i):
            is_prime[j] = False

prime_numbers = [i for i in range(sqn+1) if is_prime[i]]

nn = n
ans = []
for p in prime_numbers:
    while nn % p == 0:
        nn = nn // p
        ans.append(p)
if nn != 1:
    ans.append(nn)
print('{}: '.format(n), end = '')
print(*ans)

Solution (Python):
import math
a=int(input())
b=int(math.sqrt(a))+1

print(str(a)+":",end="")
for i in range(2,b):
    while a%i==0:
        print(" "+str(i),end="")
        a=a//i
if a!=0 and a!=1:
    print(" "+str(a),end="")
print()

Solution (Python):
import math

n = int(input())

soinsu = []

c = n
if (c % 2 == 0):
    while True:
        soinsu.append(2)
        c = c // 2
        if ( c % 2 != 0):
            break

len = int(math.sqrt(c)) + 1
for i  in range (3,len,2):
    while True:
        if ( c % i != 0):
            break
        soinsu.append(i)
        c = c // i
    if ( c == 1):
        break
if ( c != 1):
    soinsu.append(c)

print (n,":",sep="",end="")
for i in soinsu:
    print (' {}'.format(i),sep="",end="")
print("")

Solution (Python):
N = int(input())

res = []
x = N
y = 2
while y*y <= x:
    while x % y == 0:
        res.append(y)
        x //= y
    y += 1
if x > 1:
    res.append(x)
print("%d:" % N, *res)

Solution (Python):
import math
n = int(input())
num  = [str(n)+":"]
i = 2
while i <= math.sqrt(n):
    while n % i == 0:
        num.append(str(i))
        n//=i
    i+=1
if n != 1:
    num.append(str(n))
print(num[0]+" "+str(n) if len(num) == 1 else " ".join(num))

Solution (Python):
N = int(input())


def prime_factorization(n):
    table = []
    for x in range(2, int(n**0.5)+2):
        while n % x == 0:
            table.append(x)
            n //= x
    if n > 1:
        table.append(n)
    return table


print("{}:".format(N), *prime_factorization(N))

Solution (Python):
from math import sqrt
n = int(input())
k = int(sqrt(n))
Primes = [False,False]
for i in range(k + 2):
    Primes.append(True)
for i in range(2, k + 1):
    if Primes[i]:
        j = 2 * i
        while j < k + 1:
            Primes[j] = False
            j += i
primes = [i for i in range(k + 1) if Primes[i]]
del(Primes)
ans = []
index = 0
tmp = n
while n > 1 and len(primes) > index:
    if n % primes[index] == 0:
        n /= primes[index]
        ans.append(str(primes[index]))
    else:
        index += 1
if n != 1:
    ans.append(str(int(n)))
print(str(tmp) + ": " + " ".join(ans))

Solution (Python):
n = int(input())
print('{}:'.format(n), end='')
i = 2
while i <= int(n ** .5):
    if n % i == 0:
        n //= i
        print('', i, end='')
    else:
        i += 1
if n != 1:
    print('', n)

Solution (Python):
import math

def primeFactors(n):
	result = list()
	while n % 2 == 0:
		result.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			result.append(i)
			n = n / i
	if n > 2:
		result.append(n)
	return sorted(result)

n = int(input())
print('%d:' % (n), end='')
result = primeFactors(n)
for i in range(len(result)):
	print(' %d' % (result[i]), end='' if i < len(result) - 1 else '\n')

Solution (Python):
def smallest_factor(integer):
    j = 2
    while j :
        if j ** 2 > integer:
            return integer
        elif integer % j == 0:
            return j
        else:
            j += 1

n = int(input())
start = str(n)
prime_factors = []
while n >= 2:
    prime_factors.append(str(smallest_factor(n)))
    n //= smallest_factor(n)

print(start +  ': '+ ' '.join(prime_factors))

Solution (Python):
n=int(input())
ans=[str(n)+":"]
i=2
while i*i<=n:
    while n%i==0:
        n//=i
        ans.append(i)
    i+=1
if n!=1:ans.append(n)
print(*ans)