SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Y Daniel Lang
Chapter:
0.lists
Exercise:
Programming Excercises
Question:6 | ISBN:978013274719 | Edition: 6

Question

Revise Listing 5.13, PrimeNumber.py) Listing 5.13 determines whether a number n is prime by checking whether 2, 3, 4, 5, 6, ..., n/2 is a divisor for n. If a divisor is found, n is not prime. A more efficient approach is to check whether any of the prime numbers less than or equal to \sqrt{n} can divide n evenly. If not, n is prime. Rewrite Listing 5.13 to display the first 50 prime numbers using this approach. You need to use a list to store the prime numbers and later use them to check whether they are possible divisors for n

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Sorry the answer is not available at the moment…

If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.

Spread the 'tradition of sharing'.