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
n = int(input())
nc = n
result = []
i = 2
while i <= math.sqrt(n):
    if n%i == 0:
        n //= i
        result.append(str(i))
    else:
        i += 1
if n != 1:
    result.append(str(n))
print(str(nc) + ": " + " ".join(result))

Solution (Python):
import math
n=input()
N=n
a=[]

x=2
while x*x<=N:
	while n%x==0:
		a.append(str(x))
		n=n/x
	if n==1: break
	x+=1
else:
	a.append(str(n))


print str(N)+": "+" ".join(a)

Solution (Python):
import math

def simple_prime_factrize(x):
    pfs = []
    s = math.sqrt(x)
    for y in range(2, math.ceil(s)):
        if x == 1: break
        while True:
            if x%y == 0:
                pfs.append(y)
                x = x/y
            else:
                break
    if len(pfs) == 0:
        pfs.append(x)
    elif x > s:
        pfs.append(int(x))
    return pfs
    
n = int(input())
print(str(n) + ': ' + ' '.join([str(x) for x in simple_prime_factrize(n)]))

Solution (Python):
import math

s = "{0}:"
s2 = " {0}"
def prime_factorize(n):
	m = math.sqrt(n)+1
	i = 2
	prime = []
	while n != 1 and i < m:
		if n % i == 0:
			prime.append(i)
			n //= i
		else:
			i += 1
	if n != 1:
		prime.append(n)
	return prime
n = int(input())
lst = prime_factorize(n)
print(s.format(n),end="")
for i in range(len(lst)):
	print(s2.format(lst[i]),end="")
print()

Solution (Python):
n = int(input())
from math import sqrt,ceil

def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, ceil(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    for i in range(2, ceil(sqrt(n))+1):
        if not is_prime(i): continue
        q,r = divmod(n, i)
        if r == 0:
            n = q
            factor.append(i)
            q,r = divmod(n, i)    
            while r == 0:
                n = q
                factor.append(i)
                q,r = divmod(n, i)
    if n != 1:
        factor.append(n)
    return factor

factor = sorted(prime_factorization(n))
print("%d:"%n, *factor)

Solution (Python):
n = int(input())
a = []
now = n
for i in range(2, n):
    while now % i == 0:
        now //= i
        a.append(i)
    if i * i > n:
        break
if now != 1:
    a.append(now)
print(str(n) + ":", end = "")
for i in a:
    print(" " + str(i), end = "")
print()

Solution (Python):
import math

def make_divisors(n):
    divisors = []
    for k in range(2, math.floor(math.sqrt(n))+1):
        if n % k == 0:
            divisors.append(k)
            divisors.append(n // k)

    divisors.append(n)

    return sorted(divisors)

def main():
    n = int(input())
    original_n = n

    factors = []
    divisors = make_divisors(n)

    i = 0
    while True:
        if n == 1:
            break

        if n % divisors[i] == 0:
            n //= divisors[i]
            factors.append(divisors[i])
        else:
            i += 1

    print("{}: {}".format(
        original_n,
        " ".join(list(map(str, factors)))
    ))

main()

Solution (Python):
import math

n = m = int(raw_input())
r = int(math.sqrt(n))
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]
 
prime=[]
for i in range(r):
    if p[i]:
        prime.append(i+1)

a = []
for i in range(len(prime)):
    if n % prime[i] == 0:
        j = prime[i]
        while n % j == 0:
            n /= j
            a.append(j)
if n == m:
    print str(m)+":",m
elif n != 1:
    print str(m)+":"," ".join(map(str, a)),n
else:
        print str(m)+":"," ".join(map(str, a))

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2,int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i,cnt])
    if temp != 1:
        arr.append([temp,1])

    if arr == []:
        arr.append([n,1])

    return arr

f = factorization(n)
l = []
for i in range(len(f)):
    for _ in range(f[i][1]):
        l.append(str(f[i][0]))

ans = ' '.join(l)
print(f'{str(n)}: ' + ans)

Solution (Python):
def ifprime(n):
    if n%2==0:
        print(' 2',end="")
        return(int(n/2))
    else:
        for i in range(3,int(n**0.5)+1):
            if n%i==0:
                print(f' {i}',end="")
                return(int(n/i))
        print(f' {n}',end="")
        return(1)
n=int(input())
print(f'{n}:',end="")
while 1:
    n=ifprime(n)
    if n==1:break
print()

Solution (Python):
import math
n=int(input())
print(str(n)+":",end=" ")

ans=[]
i=2
while i<=math.sqrt(n):
    if n%i==0:
        ans.append(i)
        n=n//i
    else:
        i+=1
ans.append(n)
print(*ans)

Solution (Python):
def factorization(n):
    L=[]
    temp=n
    print(n,end='')
    print(':',end='')
    for i in range(2,int(n**(1/2)//1)+1):
        if temp%i==0:
            c=0
            while temp%i==0:
                c+=1
                temp//=i
            L.append([i,c])
            for j in range(c):
                print('',i,end='')
    
    if temp!=1:
        print('',temp,end='')
        
    print( )
    
n=int(input())
factorization(n)

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):
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)

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

Solution (Python):
def factorization(n):
    L=[]
    temp=n
    print(n,end="")
    print(":",end="")
    for i in range(2,int(n**(1/2))+1):
        if temp%i==0:
            c=0
            while temp%i==0:
                c+=1
                temp//=i
            L.append([i,c])
            for j in range(c):
                print("",i,end="")
    if temp!=1:
        print("",temp,end="")
    if L==[]:
        pass
    print()
    return L
n=int(input())
factorization(n)

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

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

Solution (Python):
b = int(input());
n = b;
a = []
while n % 2 == 0:
    a.append(2)
    n //= 2
f = 3
while f * f <= n:
    if n % f == 0:
        a.append(f)
        n //= f
    else:
        f += 2
if n != 1:
    a.append(n)

print("{}:".format(b),end = '');
for i in range(0,len(a)):
    print('',a[i],end = '');
print();

Solution (Python):
n = int(input())
a = []
x = n
y = 2
while y*y <= x:
    while x%y == 0:
        a.append(y)
        x //= y
    y += 1
if x > 1:
    a.append(x)
print('%d:'%n,*a)

Solution (Python):
n=int(input())
print(n,': ',sep='',end='')
a=2
A=[]
while a*a<=n:
    while n%a==0:
        n //= a
        A.append(str(a))
    a+=1
if n>1:
    A.append(str(n))
A=' '.join(A)
print(A)

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

print(*a)

Solution (Python):
def f(n):
    a=[]
    while n%2==0:
        a.append(2)
        n=n//2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n=n//f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return(a)
    
n=int(input())
a=f(n)
b=[str(i) for i in a]
A=" ".join(b)
print(f"{n}: {A}")

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

Solution (Python):



n = int(input())
print(n, ": ", sep = "", end = "")

pri = []
while n % 2 == 0:
   pri.append(2)
   n //= 2

for i in range(3, int(n ** 0.5 + 1)):
   while n % i == 0:
      pri.append(i)
      n //= i
   i += 2

if n != 1:
   pri.append(n)

for i in range(len(pri)):
   print(pri[i], end = "")
   if i < len(pri) - 1:
      print(" ", end = "")
print("")

Solution (Python):
n=int(input())
A=[]
B=n
while n%2==0:
    n//=2
    A.append(2)
while n%3==0:
    n//=3
    A.append(3)
while n%5==0:
    n//=5
    A.append(5)
while n%7==0:
    n//=7
    A.append(7)
if n>=10000000:
    A.append(n)
else:
    for j in range(3,n+1,2):
         while n%j==0:
            n//=j
            A.append(j)
print(B,end="")
print(':',*A)

Solution (Python):
N = int(input())
N_ = N
arr = []

for x in range(2,int(pow(N,0.5) + 1)):
    while N % x == 0:
        arr.append(x)
        N = N // x

if N != 1:
    arr.append(N)

print(f"{N_}:", *arr)

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

Solution (Python):
import sys

input = sys.stdin.readline


def calc_prime_factors(n, count=False):
    """Trial division"""
    factors = []
    
    while n % 2 == 0:
        factors.append(2)
        n //= 2
    
    f = 3
    root_n = int(n ** 0.5) + 1
    while f <= root_n:
        if n % f == 0:
            factors.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        factors.append(n)
    return factors


def main():
    N = int(input())

    factors = calc_prime_factors(N)

    print("{}:".format(N), " ".join(map(str, factors)))


if __name__ == "__main__":
    main()

Solution (Python):
import math
n = int(input())
m = n
l = []
for i in range(2, int(math.sqrt(n))+1):
    while m % i ==0:
        l.append(i)
        m = m // i
        if m == 1:
            break

if m != 1:
    l.append(m)
print("{}: ".format(n),end="")
print(*l)

Solution (Python):
def fact(n):
    from subprocess import Popen, PIPE
    return [*map(int, Popen(["factor", str(n)], stdout=PIPE).communicate()[0].split()[1:])]
n = int(input())
print(f"{n}:", *fact(n))

Solution (Python):
n = int(input())
x =[]

y = 2
z = n

while y*y <= z:
    while z % y == 0:
        x.append(y)
        z = z//y
    y += 1
    
if z > 1:
    x.append(z)

print("%d:" % n,*x)

Solution (Python):
n = int(input())
N = n
print(N,":",sep="",end=" ")

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    b = 3
    while b * b <= n:
        if n % b == 0:
            a.append(b)
            n //= b
        else:
            b += 2
    if n != 1:
        a.append(n)
    return a
    
A = prime_factorize(n)
print(*A)

Solution (Python):
n = int(input())
factors = []
p = 2
m = n
while p * p <= m:
    if m % p == 0:
        m //= p
        factors.append(p)
        
    else:
        p += 1
if m != 1:
    factors.append(m)
print(f'{n}:', *factors)

Solution (Python):


def factorization(n):
    ans = []
    _max = int(n ** 0.5 + 1)
    while n % 2 == 0:
        n //= 2
        ans.append(2)
    for i in range(3, _max+1, 2):
        while n % i == 0:
            n //= i
            ans.append(i)
    if n != 1:
        ans.append(n)
    return ans


n = int(input())
ans = factorization(n)

print(n, ": ", sep="", end="")
print(*ans)

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):
n = int(input())

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

Solution (Python):


import math


n = int(input())


ans = []
t = n
while True:
    is_prime = True
    for i in range(2, int(math.sqrt(t)) + 1):
        if t % i == 0:
            ans.append(i)
            t /= i
            is_prime = False
            break
    if is_prime:
        ans.append(t)
        break
ans = map(int, ans)


print(f"{n}:", " ".join(map(str, ans)))

Solution (Python):
n = int(input())
def function(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    
    if n != 1:
        a.append(n)
    
    return a

a = function(n)
print("{0}:" . format(n), end=" ")
for i in range(len(a) - 1):
    print(a[i], end=" ")
print(a[len(a) - 1])

Solution (Python):
n = int(input())
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

if __name__ == '__main__':
    print(n,end=":")
    print("",*prime_factors(n))

Solution (Python):
N = int(input())
n = N
ans = []
for i in range(2,int(N**0.5)+1): 
    while(n%i==0):
        n //= i 
        ans.append(i)
if n!=1:
    ans.append(n)
ans = [str(a) for a in ans]
ans = str(N)+": " + " ".join(ans)
print (ans)

Solution (Python):
import math
n = int(input())

x = n
ans = []
i = 2
while i <= math.sqrt(n):
    if n % i == 0:
        n = n //i
        ans.append(str(i))
    else:
        i += 1
if n != 1:
    ans.append(str(n))
print(str(x) + ":" + " " + " ".join(ans))

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

Solution (Python):
def s(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
n=int(input())
print(f'{n}: ',end='')
print(*s(n))

Solution (Python):
n=int(input())
print(str(n) + ":",end=" ")
x=[]
a=2
while a*a<=n :
    while n%a == 0:
        x.append(a)
        n=n//a
    a+=1
if n>1:
    x.append(n)
print(' '.join(str(k) for k in x))

Solution (Python):
p=lambda x:print(x,end=' ')
n=input();p(n+':')
m=n=int(n)
while n%2==0 and n>3:p(2);n//=2
d=3
while d*d<m and n>d:
 if n%d>0:d+=2
 else:p(d);n//=d
print(n)

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):
def factorization(n):
    L=[]
    temp=n
    print(n,end="")
    print(":",end="")
    for i in range(2,int(n**(1/2)//1)+1):
        if temp%i==0:
            c=0
            while temp%i==0:
                c+=1
                temp//=i
            L.append([i,c])
            for j in range(c):
                print("",i,end="")
    if temp!=1:
        print("",temp,end="")
    
    print()
   
n=int(input())
factorization(n)

Solution (Python):



n = int(input())
factors = []

p = 2
m = n
while p*p <= m:
    if m % p == 0:
        factors.append(p)
        m //= p
    else:
        p += 1
if m > 1:
    factors.append(m)

print(f'{n}:', *factors)

Solution (Python):
def soinnsuubunnkai(n):
  ret = []
  for i in range(2, int(n ** (1 / 2)) + 1):
    if i > n:break
    while n % i == 0:
      n //= i
      ret.append(i)
  if n != 1:
    ret.append(n)
  return ret

n = int(input())
print(str(n)+": ",end="")
print(*soinnsuubunnkai(n))

Solution (Python):
i = 2
n = int(input())
n_ = n

ans = []

while i*i <= n:
    while n % i == 0:
        ans.append(i)
        n //= i
    i += 1

if n > 1:
    ans.append(n)

print(str(n_) + ': ' + ' '.join([str(i) for i in ans]))

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def prime_factorize(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


def main():
    N = int(readline())
    prime = prime_factorize(N)
    ans = str(N) + ':'
    for i, k in prime:
        ans += ' {}'.format(i) * k
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
b=prime_factorize(n) 
print(f'{n}: ',end="")
print(*b)

Solution (Python):
def factorization(n):
    L=[]
    temp=n
    print(n,end='')
    print(':',end='')
    for i in range(2,int(n**(1/2)//1)+1):
        if temp%i==0:
            c=0
            while temp%i==0:
                c+=1
                temp//=i
            L.append([i,c])
            for j in range(c):
                print('',i,end='')
                
    if temp!=1:
        print('',temp,end='')
    print()
        
n=int(input())
factorization(n)

Solution (Python):
def prime_fact(n):
    ret = []
    if n == 1:
        return [1]
    for d in [2] + list(range(3, int(n ** 0.5) + 1, 2)):
        while n % d == 0:
            ret.append(d)
            n //= d
    if n != 1:
        ret.append(n)
    return ret

n = int(input())
print("{}: ".format(n), end = "")
print(*prime_fact(n))

Solution (Python):
n = int(input())
p = 2
count = []

print('{}:'.format(n), end = ' ')

while p*p  <= n: 
    while n%p == 0: 
        n = n//p
        count.append(p)
    p += 1


if not n == 1:
     count.append(n)

print(*count)

Solution (Python):
n = int(input())
m = str(n) + ":"
a = True
l = n
i = 2
while a:
  if l % i == 0:
    l /= i
    m += ' ' + str(i)
    i -= 1
  a = i < l**0.5
  i += 1
if l != 1:
  m += ' ' + str(int(l))
print(m)

Solution (Python):
num=int(input())
print(str(num)+': ',end='')
i=2
a=[]
while i*i  <= num:
    while num % i == 0:
        num //= i
        a.append(i)
    i += 1
if num != 1:
    a.append(num)
    
print (*a)

Solution (Python):


import math
n = int(input())

a = n
ans = []
i = 2
while i <= math.sqrt(n):
    if n % i == 0:
        n = n //i
        ans.append(str(i))
    else:
        i += 1
if n != 1:
    ans.append(str(n))
print(str(a) + ":" + " " + " ".join(ans))

Solution (Python):
n=input()
print(n+': ',end='')
n=int(n)
x = 2
ans = []
while x * x <= n:
    while n % x == 0:
        n //= x
        ans.append(x)
    x = x + 1
if n > 1:
    ans.append(n)
print(" ".join(list(map(str, ans))))

Solution (Python):
def factorization(n):
    L=[]
    temp=n
    print(n,end="")
    print(":",end="")
    for i in range(2, int(n**(1/2)//1)+1):
        if temp%i==0:
            c=0
            while temp%i==0:
                c+=1
                temp//=i
            L.append([i, c])
            for j in range(c):
                print("",i,end="")
    if temp!=1:
        print("",temp,end='')
    if L==[]:
        pass
    print()
    return L
n=int(input()) 
factorization(n)

Solution (Python):
def ifprime(n):
    if n%2==0:
        print(' 2',end="")
        return(int(n/2))
    else:
        for i in range(3,int(n**0.5)+1):
            if n%i==0:
                print(f' {i}',end="")
                return(int(n/i))
        print(f' {n}',end="")
        return(1)
n=int(input())
print(f'{n}:',end="")
while 1:
    n=ifprime(n)
    if n==1:break
print()

Solution (Python):
def factorization(n):
    L=[]
    temp=n
    print(n,end="")
    print(":",end="")
    for i in range(2, int(n**(1/2)//1)+1):
        if temp%i==0:
            c=0
            while temp%i==0:
                c+=1
                temp//=i
            L.append([i, c])
            for j in range(c):
                print("",i,end="")
    if temp!=1:
        print("",temp,end='')
    print()
    return L
n=int(input()) 
factorization(n)

Solution (Python):
n = int(input())
m = n
result = []

for i in range(2, n+1):
    
    while m%i==0:
        m = m//i
        result.append(i)
        
    if m==1:
        break
        
    if i>n**(1/2) and m==n:
        result.append(n)
        break

print(str(n)+':', *result)

Solution (Python):
def factor(n):
    a=[]
    suu=n
    for i in range(2,int(n**0.5//1)+1):
        if suu%i==0:
            sosuu=0
            while suu%i==0:
                sosuu+=1
                suu//=i
            for j in range(sosuu):
                a.append(i)
    if suu!=1:
        a.append(suu)
    print(n,end='')
    print(':',*a)
n=int(input())
factor(n)

Solution (Python):
def factorization(n):
   y=n
   list=[]
   print(n, end=":")
   for i in range(2,int(n**(1/2)//1)+1):
      if y%i==0:
         c=0
         while y%i==0:
            c += 1
            y=y//i
         list.append([i, c])
         for j in range(c):
            print("", i, end="")
   if y!=1:
      print("", y, end="")
   print()
n=int(input())
factorization(n)

Solution (Python):
def factorization(n):
    L=[]
    temp=n
    print(n,end="")
    print(":",end="")
    for i in range(2, int(n**(1/2)//1)+1):
        if temp%i==0:
            c=0
            while temp%i==0:
                c+=1
                temp//=i
            L.append([i, c])
            for j in range(c):
                print("",i,end="")
                

    if temp!=1:
        print("",temp,end="")

    print()

n=int(input()) 
factorization(n)

Solution (Python):
def factorization(n):
    L=[]
    temp=n
    print(n,end="")
    print(":",end="")
    for i in range(2, int(n**(1/2)//1)+1):
        if temp%i==0:
            c=0
            while temp%i==0:
                c+=1
                temp//=i
            L.append([i, c])
            for j in range(c):
                print("",i,end="")
    if temp!=1:
        print("",temp, end="")
    print()
n=int(input()) 
factorization(n)

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

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

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

Solution (Python):
def f(n):
    a=[]
    while n%2==0:
        a.append(2)
        n=n//2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n=n//f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return(a)
    
n=int(input())
a=f(n)
b=[str(i) for i in a]
A=" ".join(b)
print(f"{n}: {A}")

Solution (Python):
n = int(input())
x =[]

y = 2
z = n

while y*y <= z:
    while z % y == 0:
        x.append(y)
        z = z//y
    y += 1
    
if z > 1:
    x.append(z)

print("%d:" % n,*x)

Solution (Python):

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

x=factorize(n)
L=[str(a) for a in x]
L=" ".join(L)
print(f'{n}: {L}')

Solution (Python):
n=int(input())
a=2
s=[]
N=n
while a*a<=n:
    while n%a==0:
        n//=a
        s.append(str(a))
    a+=1
if n>1:
    s.append(str(n))
print(str(N) + ": " + " ".join(s))

Solution (Python):
n = int(input())
b = n
a = []

while n % 2 == 0:
    a.append(2)
    n //= 2
f = 3
while f * f <= n:
    if n % f == 0:
        a.append(f)
        n //= f
    else:
        f += 2
if n != 1:
    a.append(n)
    
print(f'{b}:',*a)

Solution (Python):
n = int(input())
m = int(n**0.5)+2
is_prime = [1]*m
is_prime[0] = is_prime[1] = 0
for p in range(2,m):
    for q in range(2*p,m,p):
        is_prime[q] = 0
primes = [p for p, c in enumerate(is_prime) if c]

print(str(n)+': ', end='')
ans = []
for p in primes:
    while n % p == 0:
        ans.append(p)
        n //= p
if n > 1:
    ans.append(n)
print(*ans)

Solution (Python):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

import math

n = ii()


def calc(x):
    nq = int(math.sqrt(x)+1)
    for i in range(2,nq +1):
        if x % i == 0:
            return x//i, i
    return -1,x

x = n
ans = []
while 1:
    x,m = calc(x)
    ans.append(m)
    if x <= 1:
        break
    

print(str(n)+': ',end='')
print(*ans)

Solution (Python):
n=int(input())
nc=n
out=[]

while n%2==0:
    out.append(2)
    n//=2

for i in range(3,int(n**0.5)+1,2):
    if n==1 : break
    while n%i==0:
        out.append(i)
        n//=i

if n!=1 : out.append(n)

print("{}: {}".format(nc," ".join(map(str,out))))

Solution (Python):
def prime_factorize(n):
    ans = []
    while True:
        if n % 2 == 0:
            ans.append(2)
            n //= 2
        else:
            break
    div = 3

    while div*div <= n:
        if n % div == 0:
            ans.append(div)
            n //= div
        else:
            div += 2

    if n != 1:
        ans.append(n)

    return ans


def eratosthenes_shieve(n):
    is_prime = [True for i in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    
    return [i for i in range(len(is_prime)) if is_prime[i]]


def eratosthenes_shieve_pf(n):
    primes = eratosthenes_shieve(int(n**0.5)+1)
    ans = []
    for p in primes:
        while n % p == 0:
            ans.append(p)
            n //= p

    if n != 1:
        ans.append(n)

    return ans


def main():
    n = int(input())
    
    ans = eratosthenes_shieve_pf(n)
    s = "{}: ".format(n)
    for i in ans:
        s += str(i) + " "
    print(s[:-1])


if __name__ == "__main__":
    main()

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

Solution (Python):
n = int(input())
num = n
A = []
b = 2
while b*b <= n:
    while n % b == 0:
        n //= b
        A.append(b)
    b += 1
if n > 1:
    A.append(n)
print(str(num)+": "+' '.join(str(f) for f in A))

Solution (Python):
import math
def soi(x):
    y = x
    a = []
    for i in range(2,int(math.sqrt(x))+1):
        while x%i == 0:
            a.append(i)
            x/=i
    if len(a)==0 or x!=1:
        a.append(int(x))
    a.sort()
    print(str(y)+':',*a)

n = int(input())
soi(n)

Solution (Python):
n = int(input())
n1 = n
a = 2
x = []
while a*a <= n:
    while n % a == 0:
        n //= a
        x.append(str(a))
    a += 1
if n > 1:
    x.append(str(n))
print(str(n1) + ": " + " ".join(x))

Solution (Python):
import math
n = int(input())


def prime_factorization(num):
    sqrt_num = math.sqrt(num)
    prime_numbers = []
    for i in range(2, int(sqrt_num) + 1):
        
        while num % i == 0:
            
            num = num / i
            prime_numbers.append(i)
    if num != 1:
        prime_numbers.append(int(num))
    return prime_numbers


print(str(n) + ":", *prime_factorization(n))

Solution (Python):
import math

N = int(input())
divided = N
prime_factor = []

for i in range(2, int(math.sqrt(N)//1)+1):
  while divided%i == 0:
      prime_factor.append(i)
      divided //= i
if divided != 1:
  prime_factor.append(divided)

print("{}: ".format(N, *prime_factor), end="")
print(*prime_factor)

Solution (Python):
n=int(input())
i=2
a=[str(n)+':']
m=n
while n>1:
  if i>m**.5:
    a.append(n)
    break
  if n%i==0:
    n//=i
    a.append(i)
  else:i+=1  
print(*a)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def prime_factorization(n):
    """
    nを素因数分解します
    """
    res = []
    for i in range(2, int(pow(n, 0.5)) + 1):
        if n % i == 0:
            ex = 0
            while n % i == 0:
                ex += 1
                n //= i
            res.append([i, ex])
    if n != 1:
        res.append([n, 1])

    return res


def resolve():
    n = int(input())
    prime = prime_factorization(n)

    res = []
    for p, ex in prime:
        for _ in range(ex):
            res.append(p)
    print(str(n) + ":", *res)


if __name__ == '__main__':
    resolve()

Solution (Python):
def prime_factorize(n):
    l = []
    s = '{}:'.format(n)
    i = 2
    while i * i <= n:
        while n % i == 0:
            l.append(i)
            n //= i
        i += 1
    if n != 1:
        l.append(n)
    for i in l:
        s += ' {}'.format(i)
    return s


if __name__ == '__main__':
    print(prime_factorize(int(input())))

Solution (Python):
def factorize(n):
  i = 2
  m = n
  factors = []
  
  while i*i <= m:
    if m%i==0:
      m //= i
      factors.append(i)
    else:
      i += 1

  if m > 1:
    factors.append(m)

  return factors

n = int(input())
primes = factorize(n)
print("{0}: {1}".format(n, " ".join(list(map(str,primes)))))

Solution (Python):
import math
import copy
n = int(input())
ncopy = copy.deepcopy(n)
ans = []
while True:
    if n % 2 == 1:
        break
    ans.append(str(2))
    n //= 2
i = 3
while True:
    if i**2 > n:
        break
    if n % i == 0:
        ans.append(str(i))
        n //= i
    else:
        i += 2
if n != 1:
    ans.append(str(n))
print(str(ncopy)+": "+(" ".join(ans)))

Solution (Python):
x=n=int(input())
a=[]
while n%2==0:
    a.append(2)
    n=n//2
m=3
while m*m<=n:
    if n%m==0:
        a.append(m)
        n=n//m
    else:
        m+=2
if n!=1:
    a.append(n)
b=''
for i in range(len(a)):
    b=b+' '+str(a[i])
    i+=1
print(str(x)+':'+b)

Solution (Python):
import math
n=int(input())
k=n
i=2
l=[]
while i**2<=n:
    while n%i==0:
        n//=i
        l.append(i)
    i+=1
if n>1:
    l.append(n)

print(k,end="")
print(":",*l)

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

Solution (Python):
n=n1=int(input())
k=int(n**0.5)
a=[]

while n%2==0:
    a.append(2)
    n=n/2

for i in range(3, k, 2):
    while n%i==0:
        a.append(i)
        n=int(n/i)

    if n==1:
        break
    if i*i>n:
        break

if n!=1:
    a.append(n)

print(n1,":",sep="", end="")

for i in range(len(a)):
    print(" ", end="")
    print(a[i], end="")

print("")

Solution (Python):

l = []
f = 3
n = int(input())
print(n,end='')
print(':',end=' ')
while n%2 == 0:
    l.append(2)
    n = n//2
while f <= n**(1/2):
    if n%f == 0:
        l.append(f)
        n = n//f
    else:
        f += 2
if n != 1:
    l.append(n)

print(' '.join(map(str,l)))

Solution (Python):


n = int(input())
def prime_factorize(n):
    a=[]
    while n%2 == 0:
        a.append(2)
        n //= 2
    f=3
    while f*f <= n:
        if n%f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

print(n,end='')
print(':',end=' ')
print(*prime_factorize(n))