Methods #106 (Still no quotients?...)
Code
/// Name: Amir Salehi
/// Period: 7
/// Program Name: FindingPrimeNumbers
/// File Name:FindingPrimeNumbers.java
/// Date Finished: 4/12/2016
public class FindingPrimeNumbers
{
public static void main( String[] args )
{
System.out.println();
for ( int n = 2; n <= 20; n ++ )
{
if ( isPrime(n) == true )
System.out.println( n + " < " );
else
System.out.println( n );
}
System.out.println();
}
public static boolean isPrime( int n )
{
boolean result;
int x = 0;
for ( int y = 2; y < n; y++ )
{
if ( n % y == 0 )
x++;
else
x = x;
}
if ( x > 0 )
result = false;
else
result = true;
return result;
}
}
Picture(s) of the output