+ 5
Whats wrong with my code...
Maybe something's wrong it does not work properly https://code.sololearn.com/cLLFnMFqRRR7/?ref=app
3 Respuestas
+ 1
I'm replacing it with another variable but it is not working
Please fix it for me
0
the variable you use in the for-loop and the variable you incrment is the same
0
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
boolean isPrime = true;
for(int i=2;i<a;i++){
if(a % i == 0){
isPrime = false;
break;
}
}
if(isPrime){
System.out.println ("Prime");
}
else{
System.out.println ("Not Prime");
}
}
}