Given a positive integer, write a function that computes the prime factors that can be multiplied together to get back the same integer.
Given a positive integer, write a function that computes the prime factors that can be multiplied together to get back the same integer.
4 views
1 Answers
def primeFactorization(num):
factors = [ ]
lastresult = num
# 1 is a special case
if num == 1:
return [ ]
while True:
if lastresult == 1:
break
c = 2
while True:
if lastresult % c = = 0:
break
c += 1
factors.append(c)
lastresult/= c
return factors
4 views
Answered