Hi!
So im having trouble with this code, bascially all i need (i think) is some sort of solution to
test if a number is a prime...
import java.io.*;
public class prac5prime2try2 {
// main method
public static void main(
String args[]) throws IOException {
BufferedReader myInput = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a value: ");
int n = Integer.parseInt(myInput.readLine());
System.out.println("The number entered was "+n);
// loop up to n, and check every number if it's a prime.
for(int i = 1; i <= n; i++) {
if(isPrime(i)) { // this is the same as: if(isPrime(i) == true)
System.out.println (i+" is a prime number");
}
else {
System.out.println (i+" is not a prime number");
}
}
}
*********************this is where i need help********************
// Method to test if a number is prime
private static boolean isPrime(int num) {
if(num < 2) return false;
return true;
}
}