Assignemnt #106 and Finding Prime Numbers
Code
/// Name: Marco Correa
/// Period: 5
/// Program Name: Finding Prime Numbers
/// File Name: Finding Prime Numbers.java
/// Date Finished: 3/20/2016
public class FindingPrimeNumbers
{
public static void main ( String[] args )
{
for ( int n = 2; n <= 100; n++ )
{
if ( isPrime( n ) )
{
System.out.println( n );
}
}
}
public static boolean isPrime( int n )
{
boolean prime = true;
for ( int i = 2; i < n; i++ )
{
prime = true;
if ( n % i == 0 )
{
prime = false;
break;
}
}
return prime;
}
}
Picture of the output