Created
November 6, 2024 22:32
-
-
Save eduardogpg/f3ff9610e221aa6e22bccbfddc0e580f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from threading import Thread | |
from multiprocessing import Process | |
def is_prime(number): | |
if number < 2: | |
return False | |
for x in range(2, number): | |
if number % x == 0: | |
return False | |
return True | |
numbers = [ | |
174440041 | |
] | |
if __name__ == '__main__': | |
start = time.time() | |
threads = [] | |
for number in numbers: | |
t = Process(target=is_prime, args=(number,)) | |
t.start() | |
threads.append(t) | |
for t in threads: | |
t.join() | |
print(f'Time taken: {time.time() - start}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment