For Loop- primeCheck - Java
Easy Accuracy: 46.73% Submissions: 12278 Points: 2

What do you do when you need to execute certain statements more than once? You put them in a loop. Loops are very powerful. Majority of coding questions need loops to work. You can't even input testcases without loops!

Here, we will use for loop and check if the given number n is prime or not.
Note: A number is prime if it's divisible by itself and 1. Also, 1 is not prime.

Example 1:

Input:
1

Output:
No

Example 2:

Input:
2

Output:
Yes

User Task:
Your task is to complete the provided function.

Constraints:
1 <= a <= 1000

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.