diff --git a/isPrime.java b/isPrime.java index ff51cc521..14676eea5 100644 --- a/isPrime.java +++ b/isPrime.java @@ -1,14 +1,14 @@ import java.util.*; -public class B{ +public class Main{ public static void main(String args[]){ - System.out.println("Enter a Number"); + System.out.println("Enter a Number:"); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); - if(isPrimeNumber(n)) - System.out.println("This is a Prime Number"); + if(isPrimeNumber(n)==true) + System.out.println(n+" is a Prime Number"); else - System.out.println("This is not a Prime Number"); + System.out.println(n+" is not a Prime Number"); } static boolean isPrimeNumber(int n) { @@ -16,8 +16,6 @@ static boolean isPrimeNumber(int n) { return false; if (n==2) return true; - if (n%2==0) - return false; for(int i=3;i*i<=n;i+=2) { if(n%i==0) return false; @@ -25,3 +23,4 @@ static boolean isPrimeNumber(int n) { return true; } } +