Challenge 2: Check for Prime Number
What is a prime number?
A prime number is a number greater than 1 that has only two divisors: 1 and the number itself. The first few prime numbers are:
Composite numbers are numbers that are not prime; that is, they have divisors other than and itself
The numbers and are neither prime nor composite.
All the numbers are either prime or composite, except for and .
Write a recursive method, named
isPrime() that checks if a number is prime or not.
- The method should take two integers as input.
- The method should return Boolean, meaning it will return true if the number is prime or return false if the number is not prime.
- The method should be recursive.
Sample Input: 7
Sample Output: true
Sample Input: 9
Sample Output: false