subject

Consider the task of writing a method named countfactors that accepts an integer (assumed to be positive) as its parameter and returns a count of its positive factors. for example, the six factors of 12 are 1, 2, 3, 4, 6, and 12, so the call countfactors(12) should return 6. the following is an attempt at solving the problem, but it is incorrect. determine what is wrong with the code, and submit a corrected version that works properly. public static int countfactors(int n) {
for (int i = 1; i < = n; i++) {
if (n % i == 0) { // a factor
return i;
}
}
}

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 07:00, MissSmartyPants88
To produce a starlight effect in her photograph, lina should choose the filter for her camera.
Answers: 1
image
Computers and Technology, 23.06.2019 14:00, allison9746
Need ! will choose brainliest! discuss the role of abstraction in the history of computer software.
Answers: 1
image
Computers and Technology, 23.06.2019 17:00, chrisgaz14
The more powerful, 60 volt cables and the main power shut off on an hev are both colored orange
Answers: 1
image
Computers and Technology, 23.06.2019 21:00, tiffg2588
Will this setup result in what kathy wants to print?
Answers: 2
You know the right answer?
Consider the task of writing a method named countfactors that accepts an integer (assumed to be posi...

Questions in other subjects:

Konu
English, 18.06.2020 02:57
Konu
History, 18.06.2020 02:57