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):
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):
import math
n = int(input())
pri  = [str(n)+":"]

i = 2
while i <= math.sqrt(n):
    while n % i == 0:
        pri.append(str(i))
        n//=i
    i+=1

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

L=[str(pri) for pri in pri]
L=" ".join(L)
print(L)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
ans = '{}:'.format(n)

prime_factors = []
i = 2
while i ** 2 <= n:
    ext = 0
    while n % i == 0:
        ext += 1
        n //= i
    if ext:
        prime_factors.append((i, ext))
    i += 1

if n != 1:
    prime_factors.append((n, 1))

for pf, num in prime_factors:
    ans = '{} {}'.format(ans, ' '.join([str(pf)] * num))

print(ans)

Solution (Python):
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
N = int(input())
ans = map(str,sorted(prime_factorize(N)))
print(str(N)+': '+' '.join(ans))

Solution (Python):
import math
n = int(input())
a = []
b = n
for i in range(2,int(math.sqrt(n+1))+10):
    while b % i == 0:
        b //= i
        a.append(i)
    
if b != 0 and b != 1:
    a.append(b)

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

Solution (Python):
def prime(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())
r=prime(n)
R=map(str,r)
u=' '.join(R)
print("{}: {}".format(n,u))

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

def factorize_rec(n, factor):
    for i in range(2, math.floor(math.sqrt(n)) + 1):
        if n % i == 0:
            factor.append(i)
            return factorize_rec(n/i, factor)
    factor.append(int(n))
    return factor

def factorize(n):
    return factorize_rec(n, [])

print(str(n) +":", end=" ")


print(*factorize(n), sep=' ')

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

def factorize(n: int) -> list:
    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(f'{n}:', *(factorize(n)))

Solution (Python):
import sys
import itertools

import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
n = N

ans = defaultdict(int)
i = 2
while i ** 2 <= n:
    count = 0
    while n > 1:
        if n % i != 0:
            break
        n //= i
        count += 1
    if count > 0:
        ans[i] = count
    i += 1
if n > 1:
    ans[n] = 1
print(str(N) + ':', end="")
for i, count in ans.items():
    for j in range(count):
        print(" ", end="")
        print(i, end="")
print()

Solution (Python):

def prime_factorize(n):
    res = []
    a = 2
    while a*a <= n:
        if n % a == 0:
            while n % a == 0:
                n //= a
                res.append(str(a))
        a += 1
    
    if n != 1:
        res.append(str(n))

    return res

n = int(input())
ans = prime_factorize(n)

print(str(n) + ": " + " ".join(ans))

Solution (Python):
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
n=int(input())
l=factorization(n)
ans=[]
for item in l:
    a=item[0]
    b=item[1]
    for i in range(b):
        ans.append(str(a))
print(str(n)+": "+" ".join(ans))

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



def prime_divide(n):
    res = []
    i = 2
    while True:
        if n % i == 0:
            res.append(i)
            n //= i
        else:
            i += 1
            if i > n ** (0.5):
                break
    if n != 1:
        res.append(n)
    return res


print(n, end="")
print(":", *prime_divide(n))

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):
n = int(input())
tmp = n
fact =  []
for i in range(2,int(-(-n**0.5//1))+1):
    while tmp%i == 0:
            fact.append(str(i))
            tmp //= i
            
if tmp != 1:
    fact.append(str(tmp))


            
print(str(n) + ': ' + " ".join(fact))

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

Solution (Python):
import math

def prime_factorization(n):
    factors = []
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            while True:
                factors.append(i)
                n //= i
                if n % i != 0: break
    if n > 1:
        factors.append(n)
    return factors

n = int(input())
factors = prime_factorization(n)
print(f'{n}:', *factors)

Solution (Python):
from math import sqrt

n = int(input())

out = [str(n) + ":"]

for i in range(2, int(sqrt(n)) + 1):
    while n % i == 0:
        n //= i
        out.append(str(i))

if n != 1 and n not in out:
    out.append(str(n))

print(" ".join(out))

Solution (Python):

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(str(f))
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(str(n))
    return a

def main():
    n = int(input())
    ans = prime_factorize(n)
    print(str(n) + ': ' + ' '.join(ans))

if __name__ == "__main__":
    main()

Solution (Python):


def prime_factors(n):       
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            yield i
    if n > 1:
        yield n

N = int(input())

P = list(prime_factors(N))     


print(str(N) + ":", *P)

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


"""Compute the prime factorization of the given integer by trial division.

Verification: [NTL_1_A](https://example.com)
"""

import math


def factorize_trial_division(n):
    """Compute the prime factorization of the given integer `n` by trival division.

    Returns: the prime factors as a list.
    """
    factors = []
    if n < 2:
        return factors
    for p in range(2, math.ceil(math.sqrt(n)) + 1):
        if p * p > n:
            break
        while n % p == 0:
            factors.append(p)
            n //= p
    if n > 1:
        factors.append(n)
    return factors


def main():
    n = int(input())
    fs = factorize_trial_division(n)
    print("{}:".format(n), *fs)


if __name__ == '__main__':
    main()

Solution (Python):
def 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

n = int(input())
print(str(n)+':', ' '.join([str(i) for i in factorize(n)]))

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

def pfact(m):
	pf = {}
	for i in range(2,int(m**0.5)+1):
		while m%i == 0:
			pf[i] = pf.get(i,0) + 1
			m //= i
	if m>1 : pf[m]=1
	return pf

ansl = [f"{n}:"]
for i, j in pfact(n).items():
	for _ in range(j):
		ansl.append(str(i))
print(" ".join(ansl))

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

Solution (Python):
def main():
    n = int(input())
    def factorization(n):
        arr = []
        tmp = n
        
        for i in range(2, int(-(-tmp**0.5//1))+1):
            if tmp%i == 0:
                cnt = 0
                
                while tmp%i == 0:
                    cnt += 1
                    tmp //= i
                    arr.append(i)
        
        if tmp != 1:
            arr.append(tmp)
        
        if arr == []:
            arr.append(n)
        return arr
    res = factorization(n)
    print(str(n)+': ', end='')
    for i in range(len(res)-1):
        print(res[i], end=' ')
    print(res[len(res)-1])

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
factors = []
import math
sqrt = math.floor(n ** 0.5)
z = n
for i in range(2, sqrt + 1):
    if not z % i:
        while z % i == 0:
            factors.append(i)
            z //= i
if z > 1:
    factors.append(z)
print('{}:'.format(n), *factors)

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

Solution (Python):
origin_n=int(input())
n=origin_n
dpair=[]
for i in range(2,int(n**(1/2))+1):
	k=0
	while True:
		if n//i == n/i:
			k+=1
			n/=i
		else:
			break
	if k!=0:
		dpair.append([i,k])

if n!=1:
	dpair.append([int(n),1])
print(f"{origin_n}:",end="")

for i in dpair:
	for k in range(i[1]):
		print(f" {i[0]}",end="")
print()

Solution (Python):
def prime_factorization(n):
    l = []
    i = 2
    while i * i <= n:
        if n % i == 0:
            n //= i
            l.append(i)
        else:
            i += 1
    if n > 1:
        l.append(n)
    return l


if __name__ == '__main__':
    n = int(input())
    ans = str(n) +  ':'
    ret = prime_factorization(n)
    for e in ret:
        ans += f' {e}'
    print(ans)

Solution (Python):
import math


def sieve_of_eratosthenes(N):
    prime_list = []
    for i in range(0, N):
        if i * i > N:
            break
        prime_list.append(True)
    prime_list[0] = prime_list[1] = False
    prime = []
    n = len(prime_list)
    for i in range(2, n):
        if prime_list[i]:
            prime.append(i)
            for j in range(2 * i, n, i):
                prime_list[j] = False
    return prime


def cal_count(prime, N):
    for i in range(len(prime)):
        if N < prime[i]:
            break
        while N % prime[i] == 0:
            print('', prime[i], end='')
            N //= prime[i]
    if N != 1:
        print('', N, end='')
    print()


def main():
    N = int(input())
    prime = sieve_of_eratosthenes(N)
    prime.append(N)
    print(N,end='')
    print(':', end='')
    cal_count(prime, N)


if __name__ == '__main__':
    main()

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

n = int(input())
prime_factorize(n)
print('{}:'.format(n), *prime_factorize(n))

Solution (Python):
n = int(input())
F = {}
tmp = n
i = 2
while i**2 <= tmp:
    cnt = 0
    while tmp % i == 0:
        cnt += 1
        tmp //= i
    if cnt > 0:
        F[i] = cnt
    i += 1
if tmp != 1 or F == {}:
    F[tmp] = 1
G = []
for p in F:
    for i in range(F[p]):
        G.append(str(p))
G = ' '.join(G)
print(f'{n}: {G}')

Solution (Python):
n=int(input())
P=list()
N=n
y=2
while y*y<=N:
    while N%y==0:
        P.append(y)
        N//=y
    y+=1
if N>1:
    P.append(N)
print(n,":",sep="",end="")
print("",*P,sep=" ")

Solution (Python):
def main():
    import sys
    N = int(sys.stdin.readline())
    SN = N
    def calc(N):
        import math
        L = []
        for i in range(2, int(math.sqrt(N))+2):
            while N % i==0:
                L += [i]
                N = N//i
        if N !=1:
            L += [N]
        print(str(SN) + ': ' + ' '.join(map(str,L)))
    
    calc(N)
   

if __name__=='__main__':
    main()

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

n=int(input())
s=str(n)+':'
arr=factorization(n)
for x,y in arr:
    s+=(' '+str(x))*y
print(s)

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

print(str(n)+': ',end="")

ans=[]

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):
def prime_factorize(N):
    
    import math as m
    a = []
    for i in range(2, int(m.sqrt(N)) + 1):
        while N % i == 0:
            a.append(i)
            N //= i
    if N > 1:
        a.append(N)
    return a


def resolve():
    N = int(input())
    a = prime_factorize(N)
    print(str(N) + ":", *a)


resolve()

Solution (Python):
def prime_factorization(n):
    """
    nを素因数分解して素因数のリストを返却する
    """
    if n < 2:
        return [n]

    primes = []
    while n % 2 == 0:
        primes.append(2)
        n //= 2
    i = 3
    while i ** 2 <= n:
        while n % i == 0:
            primes.append(i)
            n //= i
        i += 2
    if n != 1:
        primes.append(n)
    return primes


n = int(input())

print('{}: {}'.format(n, ' '.join(map(str, prime_factorization(n)))))

Solution (Python):
import math
def prime_factorize(n):
    i = 2
    factors = []
    while i <= math.floor(n**0.5):
        if n%i == 0:
            factors.append(i)
            n //= i
        else:
            i += 1
    if n>1:
        factors.append(n)
    return factors
N = int(input())
ans = ""
ans += str(N)
ans += ":"
ans += " "
S = prime_factorize(N)
S.sort()
for i in range(len(S)):
    if i == len(S)-1:
        ans += str(S[i])
    else:
        ans += str(S[i])
        ans += " "
print(ans)

Solution (Python):

def is_prime(N):
    i = 0
    if N <= 1:
        return False, i
    i = 2
    while i*i <= N:
        if N%i == 0:
            return True, i
        i += 1
    return True, N

N = int(input())
print(str(N)+': ', end='')
ans = []
while True:
    F, i = is_prime(N)
    if F:
        ans.append(i)
        N //= i
    else:
        print(' '.join(map(str, ans)))
        break

Solution (Python):



import math

n = int(input())
origin = n
ans = []

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

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

print(f'{origin}: {" ".join(ans)}')

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):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

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

Solution (Python):
def Eratosthenes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n ** 0.5) + 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(n + 1) if is_prime[i]]

n = int(input())
n2 = n

if n < 2:
    print(n)
    exit()

prime_factors = [] 
for i in Eratosthenes(int(n ** 0.5)):
    if i**2 > n2:
        break
    while n2 % i == 0:
        prime_factors.append(i)
        n2 //= i
if n2 > 1:
    prime_factors.append(n2)

ans = [str(i) for i in prime_factors]
ans = " ".join(ans)
print("{}: {}".format(n, ans))

Solution (Python):
n = int(input())
n_str = str(n)
res = ''

for i in range(2, int(n//2) + 1):
    if res == '' and i > n**0.5//1:
        res = ' {}'.format(str(n_str))
        break

    while n % i == 0:
        res += ' {}'.format(str(i))
        n //= i

    if n == 1:
        break
print('{}:{}'.format(n_str, res))

Solution (Python):
import math

n = int(input())

n_sqrt = int(math.sqrt(n))

i = 1
yaku = []
while i**2<=n:
    if n%i==0:
        yaku.append(i)
        yaku.append(n//i)
    i += 1
yaku = list(set(yaku))
del(yaku[0])

ylen = len(yaku)

sosu = []
Yaku = []
for i in range(ylen):
    
    j = 1
    table = []
    while j**2<=yaku[i]:
        if yaku[i]%j==0:
            table.append(j)
            table.append(yaku[i]//j)
        j += 1
    table = list(sorted(set(table)))
    
    if len(table)==2:
        sosu.append(yaku[i])

for i in range(len(sosu)):
    for j in range(len(sosu)-1,0,-1):
        if sosu[j-1]>sosu[j]:
            sosu[j-1],sosu[j] = sosu[j],sosu[j-1]

Count = []
m = n
for i in range(len(sosu)):
    count = 0
    while True:
        m = m/sosu[i]
        count += 1
        if m%sosu[i]==0:
            pass
        else:
            Count.append(count)
            break

print(n,end='')
print(':',end=' ')
for i in range(len(sosu)):
    for j in range(Count[i]):
        if i==len(sosu)-1 and j==Count[i]-1:
            print(sosu[i])
        else:
            print(sosu[i],end=' ')

Solution (Python):
import math


def getMinprime(N):
	
	if n % 2 == 0:
		return 2
	nsqrt = int(math.sqrt(n))
	for i in range(2, nsqrt + 1):
		if n % i == 0:
			return i

	return N



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


m = n  
while n > 1:
	minprime = getMinprime(n)
	primes.append(minprime)
	n = int(n / minprime)




print('{0}:'.format(m), end='')
for i in primes:
	print(' {0}'.format(i), end='')
print()

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

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

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

if n > 1:
    factors.append(str(n))

print("{}: {}".format(n_, " ".join(factors)))

Solution (Python):
from math import sqrt

n = int(input())
orig_n = n

factor = []

i = 2
while i <= sqrt(n):
    if n % i == 0:
        factor.append(i)
        n //= i
    else:
        i += 1

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

res = f'{orig_n}: ' + ' '.join(map(str, factor))

print(res)

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

Solution (Python):

def isPrime(x):
    if x < 2:
        return 0
    elif x == 2:
        return 1
    if x%2 == 0:
        return 0
    ir=int(x**(0.5))+1
    for i  in range(3,ir,2) :
        if x%i == 0:
            return 0
    return 1


n=int(input())
nn=n

ir=int(n**(0.5))+1
ret=[]
for i in range(1,ir):
    if n%i == 0 and isPrime(i):
        ret.append(i)

    if n%i == 0 and  (i*i != n) and isPrime(n//i):
            ret.append(n//i)

ret2=[]
for i in ret:
    while nn//i>0 and nn%i==0:
        ret2.append(i)
        nn=nn//i
        
print(str(n)+":",end="")
for i in ret2:

    print("",i,end="")
print()

Solution (Python):
n = int(input())
i = 2
print(str(n)+":",end = "")

while True:
  if n%i == 0:
    n //= i
    print("",i,end = "")
    i = 2
    if n == 1:
      print("")
      break
    continue
  if i > n**0.5:
    print("",n)
    break
  i += 1

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

print(f'{n}:', end='')
temp = n
for i in range(2, int(n**(1/2))+1):
    if temp % i == 0:
        while temp % i == 0:
            print(f' {i}', end='')
            temp //= i

if temp != 1:
    print(f' {temp}', end='')

print('')

Solution (Python):

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

N = int(input())
print('{}:'.format(N),end=' ')
print(*factorize(N))

Solution (Python):

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




a = int(input())
print(str(a)+': ',end='')
print(*prime_factor(a))

Solution (Python):


from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float('inf')


def prime_factor(n):
    res = []
    dividend = n
    divisor = 2
    while divisor ** 2 <= n:
        while dividend % divisor == 0:
            dividend //= divisor
            res.append(divisor)
        divisor += 1
    if dividend != 1:
        res.append(dividend)
    return res


n = int(input())
res = prime_factor(n)
res_str = list(map(str, res))
print(f"{n}: {' '.join(res_str)}")

Solution (Python):
n = int(input())
print(str(n) + ':', end='')
while n > 1:
    for p in range(2, n+1):
        if n % p == 0:
            n //= p
            print(' ' + str(p), end='')
            break
        elif p * p > n:
            print(' ' + str(n), end='')
            n = 1
            break
print()

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

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


n=int(input())
A=prime_factorize(n)
print("{}:".format(n),*A)

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

Solution (Python):
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    n = I()

    tmp = n
    ans = []
    factor = 2
    while factor<n**0.5 and tmp>1:
        if tmp%factor == 0:
            tmp //= factor 
            ans.append(factor)
        else:
            factor += 1
    if tmp>=2:
        ans.append(tmp)
    print(str(n)+':', ' '.join([str(i) for i in ans]))

if __name__ == '__main__':
    resolve()

Solution (Python):

import math
n = int(input());
orig = n
i = 2
l = []
while i<=math.sqrt(orig):
    while n%i== 0:
        n /= i
        l.append(i)
    i += 1
if n != 1:
    l.append(int(n))



print("{}:".format(orig), *l)

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

Solution (Python):
n = int(input())
nn = n
N = []

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

if n % 2 == 0 :
    while n % 2 == 0 :
        N.append(2)
        n //= 2
        
for i in range(3, int(nn ** (1 / 2)) + 1, 2) :
    while n % i == 0 :
        N.append(i)
        n //= i
        
if n != 1 :
    N.append(n)
    
if len(N) == 0 :
    print(n)
else :
    for i in range(len(N)) :
        if i == len(N) - 1 :
            print(N[i])
        else :
            print(N[i], sep = "", end = " ")

Solution (Python):
def make_prime_factors(n: int) -> list:
    """自然数nの素因数を列挙したリストを出力する
    計算量: O(sqrt(N))
    入出力例: 156 -> [2, 2, 3, 13]
    """
    prime_factors = []
    for k in range(2, int(n ** 0.5) + 1):
        while n % k == 0:
            prime_factors.append(k)
            n = n // k
    if n != 1:
        prime_factors.append(n)
    return prime_factors


n = int(input())
ans = make_prime_factors(n)
print('{}: {}'.format(n, ' '.join(map(str, 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):
import math

n = int(input())
nc = n
ans = list()

i = 2
while(i <= math.sqrt(n)):
  if(n % i == 0):
    ans.append(str(i))
    n = n // i
  else:
    i += 1
    
if(n != 1):
  ans.append(str(n))

print(str(nc) + ': ' + ' '.join(ans))

Solution (Python):
n = int(input())
N = str(n) + ':'
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, *prime_factorize(n))

Solution (Python):








import sys,bisect,math
sys.setrecursionlimit(15000)

N = int(sys.stdin.readline())
ret = []
n = N
for i in range(2,math.floor(pow(N,0.5))+1):
  
  while n%i==0:
    ret.append(i)
    n = n//i
if n != 1:
    ret.append(n)
print("{}: {}".format(N," ".join(map(str,ret))))

Solution (Python):
import sys
import math

def factorization(n):
    arr = []
    temp = n
    for i in range(2, math.ceil(math.sqrt(n))):
        if temp % i == 0:
            count = 0
            while temp % i == 0:
                count += 1
                temp //= i
            arr.append((i, count))

    if temp != 1:
        arr.append((temp, 1))

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

    return arr
        
n = int(sys.stdin.readline().strip())

factors = factorization(n)
ans = str(n) + ":"
for factor, count in factors:
    for i in range(count):
        ans += " " + str(factor)

print(ans)

Solution (Python):
def prime_factorize(n):
    res = []
    for i in range(2, int(n**0.5)+1):
        if n % i != 0:continue
        ex = 0
        while n % i == 0:
            ex += 1
            n = n//i
        res.append((i, ex))
    if n != 1:res.append((n, 1))
    return res

N = int(input())
res = prime_factorize(N)
ans = []
for v, ex in res:
    for _ in range(ex):
        ans.append(str(v))
print(str(N) + ":", " ".join(ans))

Solution (Python):

def factorize(n):
    if n < 4:
        return [n]
    res = []
    i = 2
    while i*i <= n:
        while n%i == 0:
            res.append(i)
            n //= i
        i += 1
    if n != 1:
        res.append(n)
    res.sort()
    return res

N = int(input())
f = factorize(N)
print(str(N)+": ", end="")
print(*f)

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

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

res = prime_factorization(n)
tmp = [str(n) + ':']
res = tmp + res

print(*res)

Solution (Python):
import math

n=int(input())
end=math.sqrt(n)
q=2
print(n,":",sep="",end="")
while(True):
    if n%q==0:
        n/=q
        print(" ",q,sep="",end="")
    else:
        q+=1
    if q>end or n==1:
        break
if n>1:
    print(" ",int(n),sep="",end="")
print()

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

n = int(input())
ans = factorize(n)




print(str(n) + ': ' + ' '.join(ans))

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

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

print("{}: {}".format(n," ".join(map(str,prime_factorize(n)))))

Solution (Python):

import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    n = int(readline())
    n_ = n

    d = {}
    i = 2
    while i * i <= n:
        if n % i == 0:
            d[i] = 1
            n //= i
            while n % i == 0:
                n //= i
                d[i] += 1
        i += 1

    if n > 1:
        d[n] = 1
    
    ans = ["{}:".format(n_)]
    for k, v in d.items():
        for _ in range(v):
            ans .append(str(k))

    print(" ".join(ans))


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
print('{}: '.format(n), end='')
A = []
i = 2
while n > 1:
    if n % i == 0:
        A.append(i)
        n //= i
    elif i**2 > n:
        A.append(n)
        break
    else:
        i += 1

print(*A)

Solution (Python):
def prime_factorize(N): 
    exponent = 0
    while N%2 == 0:
        exponent += 1
        N //= 2
    if exponent: factorization = [[2,exponent]]
    else: factorization = []
    i=1
    while i*i <=N:
        i += 2
        if N%i: continue
        exponent = 0
        while N%i == 0:
            exponent += 1
            N //= i
        factorization.append([i,exponent])
    if N!= 1: factorization.append([N,1])
    assert N != 0, "zero"
    return factorization

N = int(input())

f = prime_factorize(N)
ans = []
for i in range(len(f)):
    for j in range(f[i][1]):
        ans.append(f[i][0])



print(str(N) + ": ",end="")
print(*ans)

Solution (Python):
n = int(input())
N = n
M = int(n**0.5) + 1
prime = [2]
primeflag = [False] + [False, True]*(M//2)

for i in range(3, M, 2):
    if primeflag[i] is False:
        primeflag[i] = True
        prime.append(i)
        for j in range(2*i, M, i):
            primeflag[j] = True

ans = []

for i in prime:
    while N % i == 0:
        ans.append(i)
        N //= i
else:
    if N != 1:
        ans.append(N)

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