Finding and Printing all Prime numbers from 1 to N
<p>Here is what I have so far, and I am usually pretty good at tracing programs but i just can't figure out where i got stuck. It's supposed to get "N" and Mod it by D, which equals N-1, while D is greater than 1. And once it is done, it goes on the one number less than the original one, and does the same thing while N is greater than 2. And as for the "Count", i just added it so that I could check if the number was prime. Ex: if the count = N-2, which is basically every number from 2 to N-1, then that number is prime.</p>

<pre><code>public class Challenge14 {
  public void inti() {
    int count = 0;
    int N = 7;
    int D = N - 1;
    int A = 0;

    while (N &gt; 2) {
      D = N - 1;

      while (D &gt; 1) {
        A = N % D;
        D--;

        if (A == 0) {
          break;
        }

        else {
          count++;
        }
      }

      if (count == N - 2) {
        System.out.println(N);
      }
      N--;
    }
  }
}
</code></pre>
