Program #106

Code

   
    /// Name: Afaf Nabeeha
    /// Period: 7
    /// Program Name: Finding Prime Numbers
    /// File Name: Prime.java
    /// Date Finished: 3/8/2016 public class Prime

        public class Prime 
        {
            
                public static void main(String[] args) 
                {
                    
                    System.out.println( "2 <" );
                    for ( int i = 3; i < 21; i++ ) {
                        System.out.print( "\n" + i + " " );
                        if (isPrime(i)) {
                            System.out.print( "<" );
                        }
                    }
                }
            
                public static boolean isPrime(int n) {
                    boolean is = true;
                    for ( int i = 2; i < n; i++ ) {
                        if ( n % i == 0 ) {
                            is = false;
                        }
                    }
                    return is;
                }
            
            }

             
    

Picture of the output

Assignment 106