# Is it Prime?

Dev Skill archived problems can be discussed here.

### Is it Prime?

hello everyone i am new here and trying to solve the problems. i have submitted my answer for is it prime given below several times but it showed wrong answer anyone please help me to improve my answer.

Code: Select all
`class MyClass {    /**     * @param args the command line arguments     */    public static void main(String[] args)throws java.lang.Exception {        // TODO code application logic here                Scanner kbScanner = new Scanner(System.in);        int test = kbScanner.nextInt();        String []answer = new String[test];        if (test>0&&test<=5000) {            for (int i = 0; i <test ; i++) {                int number = kbScanner.nextInt();                if (number>=0&&number<=10000) {                    answer[i] = primeDecision(number);                }            }        }        for (int i = 0; i < answer.length; i++) {            System.out.println(answer[i]);        }    }    private static String primeDecision(int nextInt) {        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.                if (nextInt == 2) {            return "Yes";        }        else{            for (int i = 2; i <nextInt ; i++) {            if (nextInt%i == 0 ) {                return "No";            }        }    }    return "Yes";    }    }`

Posts: 28
Joined: Sat Aug 06, 2016 11:02 pm

### Re: Is it Prime?

Posts: 28
Joined: Sat Aug 06, 2016 11:02 pm

### Re: Is it Prime?

Please always format your code using the code block, like I have edited now.

Try following I/O

Input:
Code: Select all
`201`

Output:
Code: Select all
`NoNo`