Home > Back-end >  C the great god explain prime judgment issue
C the great god explain prime judgment issue

Time:09-23

#include
Void main ()
{
Int I, n;
The scanf (" % d ", & amp; n);
for(i=2; iIf I (n %==0) break;
If (iThe else puts (" Yes ");
}
Inside the for loop break and if statement didn't understand a great god to explain

CodePudding user response:

If I (n %==0) break; N, if be divided exactly by the I, is not a prime number, will exit the loop,,,,

CodePudding user response:

A prime number is divisible only 1 and itself so I start from 2 circulation gradually + + if n %==0 I prove n divisible I jump out of the loop in judging how much if I was I n itself then n is prime if I not n is not a prime number