Title Description
Write a function Gotbaha, verify that "every even number not less than 6 is the sum of two odd primes", enter an even N of not less than 6, find two prime numbers, so that their sum is n.
Input
Enter an even N of not less than 6
Output
Find two of the primes to make them n.
Sample input
80
Sample output
80=7+73
Tips
The main function is given below, and it is not required to include the following main function when committing
/* C code */
int main ()
{
int n;
int Gotbaha (int);
int prime (int);
scanf ("%d", &n);
Gotbaha (n);
return 0;
}
/* C + + code */
int main ()
{
int n;
int Gotbaha (int);
int prime (int);
cin>>n;
Gotbaha (n);
return 0;
}
The code is as follows:
#include <iostream> #include <iomanip> #include <cmath>using namespace std;int gotbaha (int n) { int prime (int); int a, B; for (a=3;a<=n/2;a=a+2) { if (prime (a)) { b=n-a; if (prime (b)) { cout<<n<< "=" <<a<< "+" <<b<<endl; Break;}}}} int prime (int m) { int i,k=sqrt (m); for (i=2;i<=k;i++) if (m%i==0) break ; if (i>k) return 1; else return 0;} int main () { int n; int Gotbaha (int); int prime (int); cin>>n; Gotbaha (n); return 0;}
Operation Result:
Suddenly feel that the problem is some uncomfortable ah,, one is not to output in the main function and the function type is int, and the other is that the output requirement is not to put a number of all cases are lost. When submitted to the OJ platform is not confirmed.
"Verification Goldbach conjecture" of OJ Brush problem