Assignemnt #106: Finding Prime Numbers

Code

    /// Name: Cassie
    /// Period: 6
    /// Program Name: Finding Prime Numbers
    /// File Name: Prime.java
    /// Date Finished: 3/14/2016
    
    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