6.6 LAB: Sieve of Sundaram In this lab, you are going to implement the "Sieve of Sundaram" algorithm which is used to find all odd prime numbers up to a specific integer. The input of the program is an integer n, which will be used to find all the odd prime numbers less than 2n+2. This algorithm is described as follows (Photo credit: Wikipedia https://en.m.wikipedia.org/wiki/File:SieveofSundaram_Animated.gif): 12 3 5e 89 10 i+j+ 2ij 11 12 13 14 15 10 17 18 19 20 List of Primes (2x 39 ) + 1 21 22 23 24 25 26 27 28 29 30 3 5 7 11 13 31 32 33 34 35 36 37 38 39 40 17 19 23 29 31 41 42 43 44 45 40 47 48 49 50 37 41 43 47 53 52 53 5455 50 58 59 59 01 07 51 57 71 73 01 02 03 04 05 ce07 08 e8 09 70 79 71 72 73 74 75 70 77 78 79 80 81 82 83 84 85 80 87 8 89 90 95 90 98 99 100

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I'm having trouble in starting this problem.

6.6 LAB: Sieve of Sundaram
In this lab, you are going to implement the "Sieve of Sundaram" algorithm which is used to find all odd prime numbers up to a specific
integer.
The input of the program is an integer n, which will be used to find all the odd prime numbers less than 2n+2.
This algorithm is described as follows (Photo credit: Wikipedia https://en.m.wikipedia.org/wiki/File:SieveofSundaram_Animated.gif):
1
4.
8.
10
i+j+ 2ij
11
12
13
14
15
16
17
18
19
20
List of Primes
(2x 39 ) + 1
21
22
23
24
25
26
27
28
29
30
3
7
11
13
31
32
33
34
35
36
37
38
39
40
17
19
23
29
31
41
42 43
44
45 46 47 48
49
50
37
41
43
47
53
51
52
53
54
55
58
57
58
59
60
59
61
67
71
73
61
62
83
64
65
66
67
88
69
70
79
71
72 73
74
75
76 77
78
79
80
81
82
83
84 85
88
87 88
89
90
91 92
93
94
95
98
97
98
99
100
Transcribed Image Text:6.6 LAB: Sieve of Sundaram In this lab, you are going to implement the "Sieve of Sundaram" algorithm which is used to find all odd prime numbers up to a specific integer. The input of the program is an integer n, which will be used to find all the odd prime numbers less than 2n+2. This algorithm is described as follows (Photo credit: Wikipedia https://en.m.wikipedia.org/wiki/File:SieveofSundaram_Animated.gif): 1 4. 8. 10 i+j+ 2ij 11 12 13 14 15 16 17 18 19 20 List of Primes (2x 39 ) + 1 21 22 23 24 25 26 27 28 29 30 3 7 11 13 31 32 33 34 35 36 37 38 39 40 17 19 23 29 31 41 42 43 44 45 46 47 48 49 50 37 41 43 47 53 51 52 53 54 55 58 57 58 59 60 59 61 67 71 73 61 62 83 64 65 66 67 88 69 70 79 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 88 87 88 89 90 91 92 93 94 95 98 97 98 99 100
• start with a list of numbers from 1 to n;
• for every pair of integers i and j where 1<= i<= j and i+j+ 2ij <= n, remove i+j+ 2ij from the list above;
finally, for each remaining number k in the list, 2k+1 is a prime number.
Ex: If the input is 1, the output is:
[3]
Ex: If the input is 2, the output is:
[3, 5]
Ex: If the input is 10, the output is:
[3, 5, 7, 11, 13, 17, 19]
Hint: Use two nested loops to go through the pairs of i and j.
Transcribed Image Text:• start with a list of numbers from 1 to n; • for every pair of integers i and j where 1<= i<= j and i+j+ 2ij <= n, remove i+j+ 2ij from the list above; finally, for each remaining number k in the list, 2k+1 is a prime number. Ex: If the input is 1, the output is: [3] Ex: If the input is 2, the output is: [3, 5] Ex: If the input is 10, the output is: [3, 5, 7, 11, 13, 17, 19] Hint: Use two nested loops to go through the pairs of i and j.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education