Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. All Factors Considered Write a program that would take a set of integers from STDIN and print to STDOUT a single integer that is

image text in transcribed

image text in transcribed

4. All Factors Considered Write a program that would take a set of integers from STDIN and print to STDOUT a single integer that is the sum of all the integers which have exactly three distinct factors excluding itself (35 pts). The input read from STDIN will be a single line of integers that will contain only integers and not contain any letters, symbols or any newline characters. Each integer is separated by a comma in the input. Few additional notes - The sum needs to be just of the integers from input array that meet the 3 factors criteria Make sure the factors are distinct in nature. See example below - If input array is {3,6,7. 9. 21, 100} then output should 27 (Sum of 21 and 6) Logic Steps See example below - If input array is {3,6,7,9, 21, 100} then output should 27 (Sum of 21 and 6) Logic Steps 3 has 1 factor (1) hence shouldn't be considered 6 has 3 factors (1, 2 and 3) hence should be considered 7 has 1 factors (1) hence shouldn't be considered 9 has 2 distinct" factors (1 and 3) hence shouldn't be considered 21 has 3 factors (1,3 and 7) hence should be considered 100 has over 3 factors (1, 2, 4, 5, 10, 20 and so on) hence shouldn't be considered Running your program with no custom test cases will test it against the test cases your submission will be evaluated on. The basic test cases have visible output and targets so you can see where your program deviates from the desired result, while the more challenging cases are hidden. There are runtime limits on each case as well, so if your submission is not algorithmically efficient, you may see that some of the larger cases time out. It is not required to pass all the test cases to pass the question, but you should attempt to make as many as possible pass

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

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

More Books

Students also viewed these Databases questions

Question

4. Who would lead the group?

Answered: 1 week ago

Question

2. What type of team would you recommend?

Answered: 1 week ago