Return to Snippet

Revision: 1305
at September 27, 2006 10:57 by gdonald


Updated Code
package com.destiney.Prime;
class Prime
{
  public static void main( String args[] )
  {
    int x, y, c = 0;
    for( x = 2; x < 1000; x++ )
    {
      if( x % 2 != 0 || x == 2 )
      {
        for( y = 2; y <= x / 2; y++ )
        {
          if( x % y == 0 )
          {
            break;
          }   
        }
        
        if( y > x / 2 )
        {
          System.out.println( x );
          c++;
        }
      }
    }
    System.out.println( "\nTotal: " + c );
  }    
}

Revision: 1304
at September 27, 2006 10:57 by gdonald


Initial Code
package com.destiney.Prime;
class Prime
{
  public static void main( String args[] )
  {
    int x, y, c = 0;
    for( x = 2; x < 1000; x++ )
    {
      if( x % 2 != 0 || x == 2 )
      {
        for( y = 2; y <= x / 2; y++ )
        {
          if( x % y == 0 )
          {
            break;
          }   
        }
        
        if( y > x / 2 )
        {
          System.out.println( x );
          c++;
        }
      }
    }
    System.out.println( "\nTotal: " + c );
  }    
}

Initial URL

                                

Initial Description

                                

Initial Title
Java prime number generator

Initial Tags
number

Initial Language
Java