title: how do i output prime numbers in descending order using a stack?
body: <pre><code>import java.util.Stack;
  
  public class Primes{
      public static void main(String[]args){
      Stack&lt;Integer&gt; stack = new Stack&lt;Integer&gt;();
  
      stack.push(null);
      //number of primes to display
      final int NUMBER_OF_PRIMES = 50;
      //number of primes to display per line
      final int NUMBER_OF_PRIMES_PER_LINE = 10;
      //count number of primes
      int count = 0;
      int number = 2;
  
      System.out.println("The first 50 primes are \n");
  
      while(count &lt; NUMBER_OF_PRIMES){
          boolean isPrime = true;
  
      for(int divisor = 2; divisor &lt;= number/2; divisor++){
          if(number % divisor == 0){
              isPrime = false;
              break;
          }
      }
      if(isPrime){
          count++;
  
          if(count % NUMBER_OF_PRIMES_PER_LINE ==0){
              System.out.println(number);
  
          }
          else
              System.out.print(number + " ");
  
      }
      number++;
      }
  }
  }
  </code></pre>