The input line contains three positive integers: r, s, and a, where (2 <= r < s < a). It is guaranteed that r is prime.
It should print YES, if s is the next prime number after r and a is the next prime number after s; otherwise, it should print NO.
Currently, I have the following isPrime() method:
boolean isPrime(int n) {
//check if n is a multiple of 2
if (n%2==0)
return false;
//if not, then just check the odds
for(int i=3;i*i<=n;i+=2) {
if(n%i==0)
return false;
}
return true;
}