Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started