Python The Sieve of Eratosthnes Prgram
A prime integer is any integer greater than 1 that is evenly divisible only by itself and 1. The Sieve of Eratosthenes is a method of finding prime numbers. It operates as follows:
Create a list with all elements initialized to 1 (true). List elements with prime indexes will remain 1. All other elements will eventually be set to zero.
Starting with list element 2, every time a list element is found whose value is 1, loop through the remainder of the list and set to zero every element whose index is a multiple of the index for the element with value 1. For list index 2, all elements beyond 2 in the list that are multiples of 2 will be set to zero (indexes 4, 6, 8, 10, etc.); for list index 3, all elements beyond 3 in the list that are multiples of 3 will be set to zero (indexes 6, 9, 12, 15, etc.); and so on.
When this process is complete, the list elements that are still set to 1 indicate that the index is a prime number. These indexes can then be printed. Write a program that uses a list of 1000 elements to determine and print the prime numbers between 2 and 999. Ignore element 0 of the list. The prime numbers must be printed out 10 numbers per line.
Sample Executions:

Prime numbers between 2 and 999 as determined by the Sieve of Eratosthenes.
2 357 11 13 17 19 23 29
31 37 41 43 47 53 59 61 67 71
73 79 83 89 97 101 103 107 109 113
127 131 137 139 149 151 157 163 167 173
179 181 191 193 197 199 211 223 227 229
233 239 241 251 257 263 269 271 277 281
283 293 307 311 313 317 331 337 347 349
353 359 367 373 379 383 389 397 401 409
419 421 431 433 439 443 449 457 461 463
467 479 487 491 499 503 509 521 523 541
547 557 563 569 571 577 587 593 599 601
607 613 617 619 631 641 643 647 653 659
661 673 677 683 691 701 709 719 727 733
739 743 751 757 761 769 773 787 797 809
811 821 823 827 829 839 853 857 859 863
877 881 883 887 907 911 919 929 937 941
947 953 967 971 977 983 991 997

Answers

Answer 1

Answer:

try this

Explanation:

def SieveOfEratosthenes(n):

  prime = [True for i in range(n+1)]

  p = 2

  while (p * p <= n):

      if (prime[p] == True):

          for i in range(p * p, n+1, p):

              prime[i] = False

      p +=1

  c=0

  for p in range(2, n):

      if prime[p]:

          print(p," ",end=" ")

          c=c+1

      if(c==10):

          print("")

          c=0

n= 1000

print("prime number between 2 to 999 as determined by seive of eratostenee ")

SieveOfEratosthenes(n)


Related Questions

How can technical writers help readers focus on important information in a set of instructions?
Technical writers can bring a reader's attention to important details in a set of instructions by ___.

1. adding an explanation and caution
2. using a highlighting technique
3. repeating the information
4. adding graphics to the introduction

Answers

Answer:

2. using a highlighting technique

Explanation:

highlighting is for to draw attention

Other Questions
The heights of 4 different people are: 1.55m, 1.52m, 1.81m, and 1.91m. The range of theseheights is: ___________is the Old Testament book that has half of its verses in poetry Each bag of trail mix weighs 3/8 pound. The combined weight of a set of bags is 3 3/4 pounds How many bags are there? An angle measures 58 less than the measure of a complementary angle. What is the measure of each angle? renaissance individualism emphasized please answer correctly !!!!! Will mark Brianliest !!!!!!!!!!!!!! Brianna evaluated the expressions 42+4 (6-2). Which number shows the correct solution. 52,58,62,68 provide a correct answer to this problem quickly please. A $146 tent was sold for 20% off. There was a sales tax of 4%. What was the discountamount, sales tax and final cost of the tent? Sabrina is building a bookend from two identical wooden rectangular prisms as shown in the figure. what is the volume of wood used in sabrina bookendsA.320 cubic centimeters B.640 cubic centimetersC.656 cubic centimetersD.672 cubic centimeters It was not common to see such a rare bird in our area, and I hoped to get a picture of it,Based on the word "common," what does rare mean as it is used in the sentence?1. exciting2. fair3. helpful4. unusual What is the surface area of the pyramid? Colette and Tycen made a quarts of lemonade to sell by the cup. Tycen's mother made 5 more cups of lemonade for them to sell. Theequation below can be used to find the number of cups of lemonade, c, they can sell when they make a quarts of lemonade.C = 40 + 5What is the greatest number of cups of lemonade Colette and Tycen can sell when q = 3? According to the survey article on mergers by Mukherjee et al, A) a minority of managers believe that diversification can be a good reason to merge.B) acquiring managers discount targets cash flows at the targets cost of capital.C) managers do not believe operating synergies to be important in merger decisions.D) managers do not use the discounted cash flow formula to value a target in a merger. PLS ASAP HELP I WILL GIVE BRAINLIESTWhat are thefocus and directrixof the graph ofy=1/16x^2? Lori had $126.89 in her bank account. She deposited $21.49 into it and then wrote a check for her car repairs for $156.61.What was the ending balance in her account?O -$51.21O $8.23O $8.23O $51.21What is the answer? Why did the French Huguenots move to Florida? Was Pan-Africanism a Nationalist movement?How do you know? The volume of the spear is 998 cm3. What is the approximate radius of the sphere? Use the formula v= 4/3 r3 and 3.14 for How did hitler, Stalin and Mussolini maintain power during the Great Depression of the 1930s? Support your answers with facts from the reading.