title: Ugly Numbers- Find 1500th UVA online judge
body: <p>Source code:</p>
  
  <pre><code>import java.util.Arrays;
  
  
  class Uglynumbers {
  
  /**
   * @param arg
   */
  public static void main(String[] args) {
      // TODO Auto-generated method stub
      long[] ugly= new long[1510];
      long inter1,inter2,inter3;
      int count=0;
      boolean found1=false,found2=false,found3=false;
  
      ugly[0]=1;
      ugly[1]=2;
      ugly[2]=3;
      ugly[3]=5;
      count=4;
      for (int i=1; i&lt;1500;i++)
      {
          found1=found2=found3=false;
          inter1= ugly[i]*2;
          inter2= ugly[i]*3;
          inter3= ugly[i]*5;
  
          for(int z=count-1;z&gt;=0;z--)
          {
              if((inter1&gt;ugly[z]) &amp;&amp; (inter2&gt;ugly[z]) &amp;&amp; (inter3&gt;ugly[z]))
                  break;
              else
              {
               if(ugly[z]==inter1)
                  found1=true;
               if(ugly[z]==inter2)
                  found2=true;
               if(ugly[z]==inter3)
                  found3=true;
              }
  
              if( found1 &amp;&amp; found2 &amp;&amp; found3)
                  break;
          }
  
          if(!found1)
          {
  
              ugly[count]=inter1;
              count+=1;
  
          }
  
          if(!found2)
          {
  
              ugly[count]=inter2;
              count+=1;
  
          }
  
          if(!found3)
          {
  
              ugly[count]=inter3;
              count+=1;
  
          }
  
          Arrays.sort(ugly,0,count);
  
  
          if(count&gt;=1500)
              break;
  
          }
  
  
  System.out.println("The 1500'th ugly number is "+ ugly[1499]);
  
  
  System.exit(0);
  
  
  }
  
  };
  </code></pre>
  
  <p>When I run this code in eclipse its working fine. But when i give it UVA online judge, am getting following run time error: ""136 - Ugly Numbers has failed with verdict Runtime error.
    This means that the execution of your program didn't finish properly. Remember to always terminate your code with the exit code 0"."</p>
  
  <p>What am missing in the code?</p>