Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Python 3: Assume a isPrime(n) function is given, write a program that generates a list of 10,000 integers from 1 to 10,000, then create

Using Python 3:

Assume a isPrime(n) function is given, write a program that generates a list of 10,000 integers from 1 to 10,000, then create 5 processes, and let each process take 5000 numbers respectively and check one by one, if a number is a prime number the result is 1, if not a prime number, the result is 0. For example, in a list [1, 2, 3, 4, 5], the result is a list of [0, 1, 1, 0, 1]. Your final result is a list of 10,000 0s or 1s.

from math import sqrt

def isPrime (n) :

if n <= 1 :

return 0

for fac in range (2, int(sqrt(n))+1) :

if n % fac == 0 :

return 0

return 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Formal SQL Tuning For Oracle Databases Practical Efficiency Efficient Practice

Authors: Leonid Nossov ,Hanno Ernst ,Victor Chupis

1st Edition

3662570564, 978-3662570562

More Books

Students also viewed these Databases questions

Question

3. Job rotation is used for all levels and types of employees.

Answered: 1 week ago