>>> def primefactors(n): ... # start the divisor at the smallest non-universal prime ... d = 2 ... # see if the number is divisible by successively higher integers ... while n > 1: ... if (n % d) == 0: ... print d ... n /= d ... else: ... d += 1 ... >>> primefactors(4810) 2 5 13 37