Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer the follow-up question. Thank you. Compute prime numbers in 0-99, with a sieve - Construct a shape (100,)booleanarrayisprime,filledwithTrueinthebeginning: > is_prime =np. ones ((100),

Please answer the follow-up question. Thank you.

image text in transcribed

Compute prime numbers in 0-99, with a sieve - Construct a shape (100,)booleanarrayisprime,filledwithTrueinthebeginning: > is_prime =np. ones ((100), dtype=bool ) - Cross out 0 and 1 which are not primes: is_prime [:2]=0 - For each integer j starting from 2, cross out its higher multiples: > N_max = int(np.sqrt(len(is_prime) - 1)) > for j in range (2,Nmax+1) : is_prime [2j::j]= False - Skim through he lp ( np. nonzero), and print the prime numbers - Follow-up: - Move the above code into a script file named prime_sieve.py - Run it to check it works - Use the optimization suggested in the sieve of Eratosthenes: 1. Skip j which are already known to not be primes 2. The first number to cross out is j2

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

Why do mergers and acquisitions have such an impact on employees?

Answered: 1 week ago

Question

2. Describe the functions of communication

Answered: 1 week ago