Home > Back-end >  Verify goldbach conjecture c language function
Verify goldbach conjecture c language function

Time:10-04

# include & lt; stdio.h>

Int main ()
{int m, x, y;
Int prime (int a);
Printf (" do input data: a \ n ");
The scanf (" % d ", & amp; M);
While ((m % 2)!=0 | | m<6)//
{
Printf (" error, both please input again! \n");
The scanf (" % d ", & amp; M);
}
For (x=1; x{y=m - x;
If (prime (x) & amp; & Prime (y))
Printf (" % d=% d + % d \ n ", m, x, y);
}
}

//int prime (int a) prime decision function
{int I, z=1;
While (a<=0)
Both please {printf (" input a data again! \n");
}
If (a==1)
Z=0;
Else if (a==2)
Z=1;
For (I=2; i{
If (a % I!=0)
continue;
Z=0;
}
Return (z);
}
 

CodePudding user response:

Dizzy, if a< prime function;=0 or undead cycle?
Judge the primes less complex
{int prime (int a)
int i;
If (a<=1) return 0;
For (I=2; iIf (a % I==0) return 0;//aliquot specification is not a prime number, direct return 0//or break out of circulation in
}
return 1;//return 1//or if the above use break, here is the return (I==a);
}
  • Related