- 1

Find prime number

31st Oct 2017, 4:06 AM
Ayesha
Ayesha - avatar
2 Réponses
31st Oct 2017, 4:20 AM
qwerty
qwerty - avatar
- 1
import java.util.Scanner; public class primenumber{ public static void main(String[] args) { int a; Scanner k=new Scanner (System.in); a=k.nextInt(); if((a==2)||(a==3)||(a==5)||(a==7)) System.out.print("this is prime number"); if ((a%2==0)||(a%3==0)||(a%4==0)||(a%5==0)||(a%6==0)||(a%7==0)||(a%8==0)||(a%9==0)) {System.out.print("this not prime num");} else if ((a/a==1) && (a/1==a)) {System.out.print("this is prime number");} } }
31st Oct 2017, 4:06 AM
Ayesha
Ayesha - avatar