Home > Back-end >  Urgent, for help, goldbach conjecture...
Urgent, for help, goldbach conjecture...

Time:11-26

# include "stdio.h"
Int main ()
{
Int a, b, c, d, k;
The scanf (" % d ", & amp; b);
If (b<=2 | | b % 2!=0)
return 0;
If (b==4)
{
Printf (" 4=2 + 2 \ n ");
return 0; }
For (a=3; a{
For (c=2, d=0; C<=a - 1; C + +)
{
If (a % c!=0)
D++;
}
If (d==a - 2)
{
K=b - a;

For (c=2, d=0; C<=k - 1; C + +)
{
If (k % c!=0)
D++;
}
If (d==k - 2 & amp; & a<=k)

Printf (" % d=% d + % d \ n ", b, a, k);
//return 0;

}
}
}




Title description

Goldbach conjecture: any even number greater than 2 can be divided into the sum of two prime Numbers (e.g., 18 + 7=11), please verify goldbach conjecture, programming tip: even for n, n is decomposed into n1 and n2 and n=n1 + n2, apparently n1 maximum n/2, first of all determine whether n1 is a prime number, if it is, then decide whether n2 is a prime number, if it is output n=n1 + n2,

Input format:
Enter an even number,

The output format:
The form of output n=n1 + n2, if there are multiple, a line of output a,

Input the sample:
Given a set of input here, for example:

44
The output sample:
Here is given the corresponding output, for example:

44=3 + 41
44=7 + 37
44=13 + 31


How do I run are all right, just can not submit the pta, solving

CodePudding user response:

# include & lt; Stdio & gt;
# include & lt; Math & gt;
Int prime (int n)
{
int i;
For (I=2; i If I (n %==0) return 0;
return 1;
}
Int main ()
{
Int a, b, c, d, n.
Printf (" please enter an even number (n> 3) : ");
The scanf (" % d ", & amp; n);
If (n<3 | | n % 2!=0)
Printf (" this value does not conform to the requirements \ n ");
The else
{
For (a=2; A. & lt;=n/2; A + +)
{
B=n - a;
C=prime (a);
D=prime (b);
If (c==1 & amp; & D==1)
Printf (" % d=% d + % d \ n ", n, a, b);
}
}
System (" pause ");
return 0;
}

CodePudding user response:

The prime () function, the for (I=2; i