Speeding up prime factorization I have written the following code for returning the list of prime factors.  Any speed-enhancing suggestions?

import math
def is_prime(num):
    for n in range(2,math.floor(math.sqrt(num)+1)):
        if num%n==0:
            return False
    return True         

def find_prime_factors(num):
    primes=[]
    for n in range(2,math.floor(num/2)+2):#The maximum value of the factor could only be half of the number
        if is_prime(num):
            primes.append(math.floor(num))
            break
        if is_prime(n) and num %n==0:
            num=num/n
            primes.append(n)
            while num%n ==0:
                num=num/n
                primes.append(n)

    return(primes)
Correctness

1 is not a prime factor:

&gt;&gt;&gt; find_prime_factors(25)
[5, 5, 1]


Performance

Primality testing is expensive.  You call is_prime() twice on every iteration of the main loop of find_prime_factors().  Furthermore, is_prime() performs trial division in much the same way that find_prime_factors() does, resulting in redundant work.