Primal numbers using Threads in Python

1

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
    
asked by anonymous 09.11.2015 / 19:29

1 answer

1

I think the individual wants to run two features at the same time. That is, count all the numbers that are prime in 60 s. While the program counts primes from 2 to x, it also counts the time limited by 60 s. When the time reaches 60 s the prime counter stops. I also try to use threads.

** It was supposed to be a comment. I apologize. I'm on the phone. **

    
16.11.2015 / 22:36