#106
Code
/// Name: Josh Bautista
/// Period: 6
/// Program Name: Finding Prime Numbers
/// File Name: P.java
/// Date Finished: 2/26/2015
public class P
{
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