Question: 10 pts Write a method divisors(int n) that returns the number of divisors of a positive integer in that is passed into the method. A
10 pts Write a method divisors(int n) that returns the number of divisors of a positive integer in that is passed into the method. A divisor of an integer n, also called a factor of n, is an integer which divides n without leaving a number. For example, the number 200 has 12 divisors (1.2.4, 5, 8, 10, 20, 25, 40, 50, 100, 200). Therefore divisors(200) should return 12. It is easy to test whether a number is a divisor or another number by the modulus operation. For example, 25 is a divisor of 200 because 200 % 25 is equal to 0; 6 is not a divisor of 200 because 200 mod 6 is equal to 2. Note: You do not need to write a main method
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
