Godbach conjecture:
If an even number greater than 6, the sum of two prime numbers can be written. It is called in line with the godebach conjecture.
# Include
# Include
///
/// Determine whether a number is a prime number //////
Number of items to be determined///
If yes, true is returned. Otherwise, false is returned.
Static bool IsPrimeNumber (int intNum) {bool blFlag = true; // identify whether it is a prime number if (intNum = 1 | intNum = 2) // determine whether the input number is 1 or 2 blFlag = true; // assign else {int sqr = (int) (sqrt (double) intNum) to the bool type variable )); // perform the square operation for the number to be judged (int I = sqr; I> = 2; I --) // cyclically {if (intNum % I = 0) from the number after the start // perform the remainder operation on the number to be judged and the specified number {blFlag = false; // if the remainder is 0, it is not a prime number} return blFlag; // return bool variable }///
/// Determine whether a number conforms to the godebach conjecture //////
Number of items to be determined///
If yes, true is returned. Otherwise, false is returned.
Static bool ISGDBHArith (int intNum) {bool blFlag = false; // identify whether it meets the godebach conjecture if (intNum % 2 = 0 & intNum> 6) // judge the number to be judged {for (int I = 1; I <= intNum/2; I ++) {bool bl1 = IsPrimeNumber (I ); // determine whether I is a prime number bool bl2 = IsPrimeNumber (intNum-I); // determine whether intNum-I is a prime number if (bl1 & bl2) {// Output Equation printf ("% d = % d + % d \ n", intNum, I, intNum-I); blFlag = true; // break; // conforms to the godebach conjecture }}return blFlag; // returns the bool variable} void main (){ Int a = 0; printf ("enter an even number greater than 6: \ n"); scanf_s ("% d", & a, 10 ); bool blFlag = ISGDBHArith (a); // you can determine whether the result is consistent with the pair of prime numbers (if (blFlag) {printf ("% d. ", A) ;}getchar (); getchar ();}