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

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.

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.