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

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 05:30
Someone plzz me which of these defines a social search? a. asking a search engine a question that is answered by a real person on the other sideb. modifying search results based on popularity of a web pagec.modifying search results based on a ranking of a web page
Answers: 2
question
Computers and Technology, 24.06.2019 17:40
Which of the following processes applications across multiple computing devices? a. functional application b. distributed system c. workgroup information silo d. information silo
Answers: 3
question
Computers and Technology, 25.06.2019 00:00
Rom is designed for computer instructions temporary storage of data processing data
Answers: 1
question
Computers and Technology, 25.06.2019 02:30
What are the charges for invasion of privacy on computers
Answers: 1
You know the right answer?
Consider the task of writing a method named countfactors that accepts an integer (assumed to be posi...
Questions
question
Mathematics, 15.12.2020 23:40
Questions on the website: 13722367