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