title: Prime Number Generator Logic
body: <p>I am supposed to make a class <code>PrimeNumberGenerator</code> which has a method <code>nextPrime</code> that will print out all prime numbers up to a number the user inputs.</p>
  
  <p>Ex) </p>
  
  <pre><code>Enter a Number: 
  20
  2
  3
  5
  7
  11
  13
  17
  19
  </code></pre>
  
  <p>Our teacher told us that we should use a nested <code>for</code> loop. I tried, but when I tried to make the inner (nested) loop, I got really confused. </p>
  
  <p>Here is my code: 
  (I'm going to make a tester class later)</p>
  
  <pre><code>public class PrimeGenerator {
  
      private int num;
      boolean isPrime;
  
      public PrimeGenerator(int n)
      {
          num = n;
      }
  
      public int nextPrime (int num)
      {
          for (int i=2; i &lt; num; i++) // The first prime number is 2 and the prime numbers only have to go up to a number the user inputs. 
          {
              for (int j = 3; j&lt;=i/2; j+=2) // The next prime number is 3 and I attempted to loop through to get the next odd number.
              {
                  if (num % i == 0) //if the number (upper limit) mod a "prime number" is 0, then that means that number is not really "prime" after all. 
                  {
                      break;
                  }
              }
          }
  
          return num;
      }
  
  }
  </code></pre>