def factors(n):
 for p in genprimes():
  while ((n != 1) and ((n % p) == 0)):
   (yield p)
   n /= p
  if (n == 1):
   break
  if ((p * p) > n):
   (yield n)
   break

def factors ( n ) : for p in genprimes ( ) : while ( ( n != 1 ) and ( ( n % p ) == 0 ) ) : ( yield p ) n /= p if ( n == 1 ) : break if ( ( p * p ) > n ) : ( yield n ) break
yields the prime factors of the integer n .