title: Check whether a number is a sum of two prime numbers
body: <p>The problem is to check a random number <code>n</code> can be the sum of 2 random prime numbers. For example, </p>
  
  <blockquote>
    <p>if n=34 the possibilities can be (3+31), (5+29), (17+17)...</p>
  </blockquote>
  
  <p>So far I have managed to save prime numbers to the array, but have no clue how I could check, if <code>n</code> is the sum of 2 prime numbers.</p>
  
  <p>This is part of my code:</p>
  
  <pre><code>public static void primeNumbers(int n) {
      int i = 0, candidate = 2, countArray = 0, countPrime = 0;
      boolean flag = true;
  
      while (candidate &lt;= n) {
          flag = true;
          for (i = 2; i &lt; candidate; i++) {
              if ((candidate % i) == 0) {
                  flag = false;
                  break;
              }
          }
          if (flag) {
              countPrime++;
          }
          candidate++;
      }
      int[] primeNumbers = new int[countPrime];
  
  
      while (candidate &lt;= n) {
          flag = true;
          for (i = 2; i &lt; candidate; i++) {
              if ((candidate % i) == 0) {
                  flag = false;
                  break;
              }
          }
          if (flag) {
              primeNumbers[countArray] = candidate;
          }
          candidate++;
          countArray++;
      }
  
      for (i = 0; i &lt;= primeNumbers.length; i++) {
  
      }
  }
  </code></pre>
  
  <p>First I counted how many prime numbers are between 1-n so I can declare and initialize my array for prime numbers. Then I save prime numbers to the array.  But now I have no idea how I could check if <code>n</code> is the sum of 2 prime numbers.</p>