title: identify prime number using recursive method [java]
body: <p>the problem is below. main() checks numbers 1-10 by calling isPrime(). I think I have the math right however every number other than 2 comes back as not prime. </p>
  
  <p>I have checked some of the solutions and questions on SO, however, I can't seem to achieve the same results. </p>
  
  <p>original problem:</p>
  
  <pre><code>public class PrimeChecker {
  // Returns 0 if value is not prime, 1 if value is prime
     public static int isPrime(int testVal, int divVal) {
        // Base case 1: 0 and 1 are not prime, testVal is not prime
  
        // Base case 2: testVal only divisible by 1, testVal is prime
  
        // Recursive Case
           // Check if testVal can be evenly divided by divVal
           // Hint: use the % operator
  
           // If not, recursive call to isPrime with testVal and (divVal - 1)
        return 0;
     }
  
     public static void main(String[] args) {
        int primeCheckVal = 0; // Value checked for prime
  
        // Check primes for values 1 to 10
        for (primeCheckVal = 1; primeCheckVal &lt;= 10; ++primeCheckVal) {
           if (isPrime(primeCheckVal, (primeCheckVal - 1)) == 1) {
              System.out.println(primeCheckVal + " is prime.");
           }
           else {
              System.out.println(primeCheckVal + " is not prime.");
           }
        }
     }
  }
  </code></pre>
  
  <p>My solution so far:</p>
  
  <pre><code>     public class PrimeChecker {
       // Returns 0 if value is not prime, 1 if value is prime
     public static int isPrime(int testVal, int divVal) {
        int resultVal = 0;
  
        if ((testVal == 0) || (testVal == 1)){
           resultVal = 0;
        }// Base case 1: 0 and 1 are not prime, testVal is not prime
  
        else if (divVal == 1) {
           resultVal = 1;
        }// Base case 2: testVal only divisible by 1, testVal is prime
  
        else {
           if((testVal % divVal != 0) &amp;&amp; (testVal / divVal == 1)) {
              isPrime(testVal, (divVal-1));
           }
           else {            
               resultVal = 1;
  
        }
        }
        return resultVal;
         }
  
        public static void main(String[] args) {
        int primeCheckVal = 0; // Value checked for prime
  
        // Check primes for values 1 to 10
        for (primeCheckVal = 1; primeCheckVal &lt;= 10; ++primeCheckVal) {
          if (isPrime(primeCheckVal, (primeCheckVal - 1)) == 1) {
              System.out.println(primeCheckVal + " is prime.");
           }
           else {
              System.out.println(primeCheckVal + " is not prime.");
           }
        }
     }
  }
  </code></pre>