Question: Write a method called printFactors that accepts an integer as its parameter and uses a fencepost loop to print the factors of that number, separated
Write a method called printFactors that accepts an integer as its parameter and uses a fencepost loop to print the factors of that number, separated by the word "and ". For example, the factors of the number 24 should print as the following:
1 and 2 and 3 and 4 and 6 and 8 and 12 and 24
You may assume that the parameter’s value is greater than 0, or you may throw an exception if it is 0 or negative.
Step by Step Solution
3.57 Rating (168 Votes )
There are 3 Steps involved in it
Prints the factors of an integer separated by Precondition n 1 public s... View full answer
Get step-by-step solutions from verified subject matter experts
