Home > Back-end >  For prime Numbers within 100
For prime Numbers within 100

Time:05-11

Prime Numbers within 100, and the computing result is wrong, want to consult everybody a great god where is wrong!

CodePudding user response:

Don't have to see, must be judging prime number has a problem,

CodePudding user response:

Prime Numbers can be involved

CodePudding user response:

refer to the second floor the wise know already should good karma response:
judge prime Numbers can join

A great god, and do you have changes

CodePudding user response:

Function f has a problem, if you (I & lt; N) and the else should be placed outside the circle, instead of should be in the loop,

 if (I & lt; N) y=0; The else y=1; 

The statement on the outside loop should be no problem, try ~

CodePudding user response:

According to the examples provide url changes,

CodePudding user response:

reference 5 floor wise men know already should good karma response:
click on url examples provided changes,

Provide the url?

CodePudding user response:

Provide the url?

CodePudding user response:

In judging prime number can be and is on the second floor link address, is this all don't know?

CodePudding user response:

The second floor of text click away for example, view the example code,

CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html

CodePudding user response:

Reference:
//method 1: 

Int f (int n)
{
int i;
If (n<=1) return 0;
for(i=2; iIf I (n %==0) break;
If (iThe else return 1;
}

//method 2:
Int f (int n)
{
int i;
If (n<=3) return n> 1;
for(i=2; I * iIf I (n %==0) retrun 0;
return 1;
}

CodePudding user response:

the wise know already, 9/f, reference shall be good karma response:
text click away on the second floor for example, see the example code,

Good, understand, thank you

CodePudding user response:

Fixed line 11 # buildings of 19: if I (n %==0) return 0;
  • Related