Home > Back-end >  What is this for loop to realize the mathematical meaning?
What is this for loop to realize the mathematical meaning?

Time:10-21

CodePudding user response:

May be judging prime

CodePudding user response:

To judge whether a prime number, if a number can be divided exactly by except 1 integer, then the divisor of the maximum number of half, so you don't need to count from one to the exhaustive calculation, so that we can reduce half of the amount of calculation

CodePudding user response:

refer to the second floor like to do in my reply:
to judge whether a prime number, if a number can be divided exactly by except 1 integer, then the divisor of the maximum number of half, so you don't need to count from one to the exhaustive calculation, so that we can reduce half of the amount of calculation

Can take a for loop calculation program block diagram? some things are not too can feel I am a novice

CodePudding user response:

The most onerous is
For (I=2; i {
If (num % I==0)
{
flag=0;
}

Now only the for (I=2; i CodePudding user response:

Identifying the prime Numbers

CodePudding user response:

 if (num % I==0) 
{
flag=0;
break;
}


Suggested to add a break out of circulation, improve the efficiency of the program,

If the aliquot, the show is not a prime number,
  • Related