Assignemnt #106 and Prime Method
Code
///Name: Daniel Tiffany-Appleton
///Period: 7
///Program Name: Prime Method
///File Name: PrimeMethod
///Date Finshed: 3/11/16
public class PrimeMethod
{
public static void main( String args[] )
{
for ( int n = 2; n <= 20; n++ )
{
isPrime( n );
if( isPrime( n ) == true )
{
System.out.println( n + " <" );
}
else
{
System.out.println( n );
}
}
}
public static boolean isPrime( int n )
{
boolean result;
int t;
result = true;
t = 0;
for( int x = 2 ; x < n ; x++ )
{
if(n % x == 0)
{
t++;
}
else
{
t=t;
}
}
if(t>0)
{
result = false;
}
else
{
result = true;
}
return result ;
}
}
Picture of the output