Question: 1) Write a method: boolean isPrime(int n) that returns true if n is prime and false otherwise. Hint: use % to test if numbers divide
1) Write a method:
boolean isPrime(int n)
that returns true if n is prime and false otherwise.
Hint: use % to test if numbers divide n.
2) Write a method:
String getFactors(int n)
that uses isPrime() and returns a String containing the primefactorization of n.
For instance: getFactors(32) returns "2 * 2 * 2 * 2 * 2", and getFactors(123467982) returns "2 * 3 * 11 * 1087 * 1721".
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
