title: Prime decomposition
body: <p>I'm trying to take a user-entered number and determine if it's a prime number or not. If it is not prime, I want to display the prime factors for that number. I need to use only JOptionPane. No matter what I try my code doesn't read any odd numbers (21, 25, 105 etc) as primes even though they are. What am I doing wrong?</p>
  
  <pre><code>    do
      {   
          enteredNum = JOptionPane.showInputDialog(null, "Please enter a positive"
                  + " integer","enter number",1);
          int number = Integer.parseInt(enteredNum); //Enter number and convert to integer
          if (number &lt; 0){
              break;
          }
  
          counter = 2;
          isPrime = true;
  
          while(isPrime &amp;&amp; (counter &lt; number)){
              if((number%counter)== 0){
                  isPrime = false;
                  JOptionPane.showMessageDialog(null, "Your entered number, "+number+" is not prime."
                          + "\nIts prime decomposition is "+counter+" X "+(number/counter)+".",
                          "Prime number", 1);
                  break;
              }
              else {
                  counter = counter + 1;
                  JOptionPane.showMessageDialog(null, number+"is a prime number", "Prime number", 1);
                  break;
              }
          }
  </code></pre>