import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter Your Number : ");
int n = in.nextInt();
System.out.println("Your Given Number :" +isPrime(n));
}
static Boolean isPrime(int n){
if(n<=1){
return false;
}
int c = 2;
while(c*c<=n){
if(n%c==0){
return false;
}
c++;
}
if(c*c > n){
return true;
}else{
return false;
}
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter