Oct-23-2017, 07:39 AM
Hello everyone ,
I have occurred in a problem with this code.The thing is that I had to find all prime numbers in a list and delete from list1 all the numbers with divisors !=t ; until that point it's all "ok", but I must find a way to make faster the finding process(for divisors) for numbers like >10000000000
I have occurred in a problem with this code.The thing is that I had to find all prime numbers in a list and delete from list1 all the numbers with divisors !=t ; until that point it's all "ok", but I must find a way to make faster the finding process(for divisors) for numbers like >10000000000
def findpandd(list1,t): primes=[] d={} for el in list1: cont=0 r=range(2,el) for i in r: if el%i==0: cont+=1 if i>(el**(1/2)) and cont==0:break if cont>t:break d.update({el: cont}) for el in d: if d[el]==0:primes+=[el] if d[el]!=t:list1.remove(el) return list1,primes