Skip to content

Instantly share code, notes, and snippets.

@eduardogpg
Created November 6, 2024 22:32
Show Gist options
  • Save eduardogpg/f3ff9610e221aa6e22bccbfddc0e580f to your computer and use it in GitHub Desktop.
Save eduardogpg/f3ff9610e221aa6e22bccbfddc0e580f to your computer and use it in GitHub Desktop.
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