## brixton d -1

hey i need a to write a program that when given an interger reduces it to prime factors. the interger is guarenteed to be less than 900

## pyTony 888

What you can then tell about the biggest possible smallest factor, when you know that we are dealing only with integers? Give some effort first yourself.

## brixton d -1

def factor (n):
"""returns a list of the prime factors of interger n"""
factors = []
p = primes.generator() # yields an infinite list
while n > 1 :
x = p.next()
while n % x == 0:
n = n/x
factors.append (x)
return factors

## pyTony 888

``````def factor (n):
"""returns a list of the prime factors of interger n"""
factors = []
p = primes.generator() # yields an infinite list
while n > 1 :
x = p.next()
while  n % x == 0:
n = n/x
factors.append (x)
return factors
``````

Could you explain your logic, especially how line 4 works and why you wrote line 6 like you wrote it and did not use for. Could you kindly also use (CODE) like I did here in my reply in your posts of code.

What is your problem? You did not ask or post any error messages.