A prime number is a number that is only evenly divisible by itself and 1. For example, the number 5 is prime because it can only be evenly divided by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6.
Write a method named isPrime, which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise.
Breaking it down
Write a isPrime method
The isPrime method determines whether a number is prime.
Primes is a utility class found in apache commons. The
Primes.isPrime is already a utility method and in this instance it is being wrapped in the
isPrime for illustration purposes.
Putting it together
- Adjust program to enable user to continously enter a number to check
- Add validation to verify input