Design an algorithm in Python to find all the prime factors of an input number.
def prime_factors(n):
    factors = []
    d = 2
    while n > 1:
        while n % d == 0:
            factors.append(d)
            n = n/d
        d = d + 1

    return factors