Why I am getting WA in this simple prime problem?

Can somebody help me by providing a test case. I just ran a loop till N and check if it is divisible by any number. If then turn the check value to 0 and print no otherwise yes. But I am getting WA. Why???

Problem Code: PRB01

My solution: https://www.codechef.com/viewsolution/48446154

you are getting wrong answer when p=1;

your output =yes;
ac output=no

1 Like

U started loop from 2.
U should add a base case for p=1.
when p=1, answer should be β€œno”, ur answer giving β€œyes”.
Add this case before the loop.
Hope it helps! :slight_smile:

True, so subtle. Thanks for reply @anumber @anon46046035