I wrote the following program to prime factorize a number:
import math def prime_factorize(x,li=[]): until = int(math.sqrt(x))+1 for i in xrange(2,until)
def primeFactorization(n): """ Return the prime factors of the given number. """ factors = [] lastresult = n while 1: if lastresult == 1: break c = 2 while 1: if lastresult % c == 0: break c += 1 factors.append(c) lastresult /= c return factors
is it fine.