Assignment #106

Code

/// Name: Jonathan Stine
/// Period: 5
/// Program Name: Finding Prime Numbers
/// File Name: Prime.java
/// Date Finished: Whenever, man...
    
    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;
        }
    
    }

    
    
 
    

Code Output