This is the code I am using to determine whether or not a number is prime:
public static boolean isPrime(int x) {
boolean isTrue = true;
for ( int y = 2; y <= x/2; y++ ) {
if ( x % y == 0 ) {
isTrue = false;
} else {
isTrue = true;
}
}
return isTrue;
}
My program is returning non-prime numbers, so I screwed up in here somewhere. Can someone please show me where?

New Topic/Question
Reply


MultiQuote









|