Assignment #106 Finding Prime Numbers

Code

    /// Name: John Huh
    /// Period: 6
    /// Program Name: Finding Prime Numbers
    /// File Name: Prime.java
    /// Date Finished: 3/29/2016
    
    public class Prime
    {
    	public static void main( String[] args )
    	{
            
            System.out.println();
            
            for ( int n = 2; n < 21; n++ )
            {
                System.out.print( n + " " );
                
                if ( isPrime(n) == true )
                {
                    System.out.print( "<" );
                }
                
                System.out.println();
            }
            System.out.println();
        }
        
        public static boolean isPrime( int n )
        {
            int x = 0;
            boolean result;
            for ( int a = 2; a < n; a++ )
            {
                if ( n % a == 0 )
                {
                    x++;
                }
                else
                {
                    x = x;
                }
            }
            if ( x > 0 )
            {
               result = false;
            }
            else
            {
                result = true;
            }
            return result;
        }
    }
    

Picture of the output

Assignment 1