Question
C++ Include include using namespace std; Question 2. [10 marks] In a given range [S..E] inclusive, report the number with the largest count of factors.
C++
Include
include
using namespace std;
Question 2. [10 marks] In a given range [S..E] inclusive, report the number with the largest count of factors. S is guaranteed to be no greater than E. No range / error checking is needed. If there exists multiple numbers having the same factor count, report the smallest one. Example 1: (user input is underlined) Input range: 1 4 4 (explanation: 4 has three factors (1,2,4), 2 and 3 has two factors, 1 has one factor) Example 2: (user input is underlined) Input range: 1 3 2 (explanation: 2 has two factors (1,2), 3 also have two factors (1,3). Answer is 2 as it's smallest) Example 3: (user input is underlined) Input range: 10 30 24 Example 4: (user input is underlined) Input range: 7 7 7
Question 2. [10 marks] In a given range [S..E] inclusive, report the number with the largest count of factors. S is guaranteed to be no greater than E. No range / error checking is needed. If there exists multiple numbers having the same factor count, report the smallest one. Example 1: (user input is underlined) Input range: 14 4 (explanation: 4 has three factors (1.2.4), 2 and 3 has two factors, I has one factor) Example 2: (user input is underlined) Input range: 13 2 (explanation: 2 has two factors (1.2), 3 also have two factors (1,3). Answer is 2 as it's smallest) Example 3: (user input is underlined) Input range: 10 30 24 Example 4: (user input is underlined) Input range: 77 7
Step by Step Solution
There are 3 Steps involved in it
Step: 1
C code along with explanations include include using namespace std int countFactorsint num int count ...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