Oct-18-2017, 02:53 PM
Hello everyone! The problem Im experiencing with this exercise is that I should make it faster. But i dont know how to do it.
The thing is: I have to find the prime numbers of list1 and print them + find the non-prime numbers and print them if they have b divisors
The thing is: I have to find the prime numbers of list1 and print them + find the non-prime numbers and print them if they have b divisors
def alpha(list1, b): numprim=[] accadiv=[] for i in list1: cont=0 for j in range(2, i): if i%j==0: cont+=1 if cont>b: break if cont!=0: numprim+=[i] print(list(set(list1)-set(numprim))) for y in list1: kappa=0 for x in range(2, y): if y%x==0: kappa+=1 if kappa>b: break if kappa==b: accadiv+=[x] print(accadiv)