Prime Factors -suggestions?

Anyone have suggestions on how to find all prime factors of a given number in GH?

Using Python?

def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
            n //= i
    if n > 1:
    return factors

a = prime_factors(x)


wow great! This is perfect. Thanks a million!
(Also this is my first time using python script component --worked like a charm!)

Great! Glad to help :slight_smile: there are doubtless more efficient algorithms out there, depending on the size of numbers you are looking at and how many times you are repeating the operation.