Assignment #106 and Finding Prime Numbers
Code
/// Name: Brendan Baird
/// Period: 6
/// Program Name: Finding Prime Numbers
/// File Name: PrimeFunction.java
/// Date Finished: 1/29/2016
public class PrimeFunction
{
public static void main(String[] args)
{
System.out.println( "2 <");
for ( int n = 3 ; n < 21 ; n++ )
{
System.out.print("\n" + n + " ");
if ( isPrime(n) == true ){
System.out.print("<");
}
}
}
public static boolean isPrime( int n )
{
boolean is = true;
for ( int x = 2 ; x < n ; x++ )
{
if ( n % x == 0 ){
is = false;
}
}
return is;
}
}
Picture of the output