Home > Back-end >  C language to 1 to N of prime Numbers, for a great god help me look at my code there is wrong why en
C language to 1 to N of prime Numbers, for a great god help me look at my code there is wrong why en

Time:12-19

#include
#include
Int sushu (int N);
Int main ()
{
Int I, N, a;
Scanf_s (" % d ", & amp; N);
For (I=2; i <=N; I++)//output prime
{
A=sushu (N);
If (a)
Printf (" % d \ n ", I);
}
return 0;
}
Int sushu (int N)//judgment prime
{
int a;
If (N & lt; 2)
return 0;
For (a=2; A. & lt;=SQRT (N); +)
{
If (a==0 N %)
return 0;
The else
continue;
}
return 1;
}

CodePudding user response:

Error
 # include & lt; stdio.h> 
#include
Int sushu (int N);
Int main (int arg c, char * argv [])
{
Int I, N, a;
Scanf_s (" % d ", & amp; N);
For (I=2; i <=N; I++)//output prime
{
A=sushu (I);//a=sushu (N); Z error here
If (a)
Printf (" % d \ n ", I);
}
system("pause");
return 0;
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Int sushu (int N)//judgment prime
{
int a;
If (N & lt; 2)
return 0;
For (a=2; A. & lt;=SQRT (N); +)
{
If (a==0 N %)
return 0;
The else
continue;
}
return 1;
}
modify as follows, for your reference:

CodePudding user response:

Thank you I already know, before the output where I write the wrong letter
  • Related