I need to create a program in python using threads that find the largest number of prime numbers in 60 seconds, but I can not understand the use of threads for it: '
import time
import math
def is_prime(number):
number = int(number)
if number == 2:
return True
num_sqrt = int(math.sqrt(number))
if number:
if number % 2 == 0:
return False
for i in range(3, num_sqrt+1, 2):
if number % i == 0:
return False
return True
def func_Prime(i):
i = 0
numero = 3
print 'PROGRAMA QUE VERIFICA E MOSTRA QUAIS OS NÚMEROS PRIMOS.'
ini = time.time()
final = 0
while(final < 1):
numero = numero+1
resposta = is_prime(numero)
if resposta:
i = i+1
primo = numero
fim = time.time()
final = fim - ini
return primo, i