Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 Find the Numbers (10 marks) To find all the numbers that are less than or equal to a given integer n by the defined

image text in transcribed

1 Find the Numbers (10 marks) To find all the numbers that are less than or equal to a given integer n by the defined method: 1 Create a list of consecutive integers from 2 through n: (2,3, 4, ..., n). 2 Initially, let p equal 2, the smallest number we want to find. 3 Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the list (these will be 2p, 3p, 4p, ...; And the p itself should not be marked). 4 Find the smallest number in the list greater than p that is not marked. If there was no such number, then go to step 5. Otherwise, p is assigned to this new number which is the next number we want to find, and repeat from step 3. 5 The numbers remaining not marked in the list are all the numbers we want to find, and we print them. Please design program to complete the task and answer what's the property of the numbers. Input: n, an integer less than 100000000. Output: numbers we want to find. Example: Input: 4 Output: 23

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

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions

Question

7. What decisions would you make as the city manager?

Answered: 1 week ago