1 #include<stdio.h> 2 #include<math.h> 3 4 int prime(int p); 5 void Goldbach(int n); 6 7 int main() 8 { 9 int m, n, i, cnt; 10 11 scanf_s("%d %d", &m, &n); 12 if (prime(m) != 0) 13 { 14 printf("%d is a prime number ", m); 15 } 16 if (m < 6) 17 { 18 m = 6; 19 } 20 if (m % 2) 21 { 22 m++; 23 } 24 cnt = 0; 25 for (i = m; i <= n; i += 2) 26 { 27 Goldbach(i); 28 cnt++; 29 if (cnt % 5) 30 { 31 printf(", "); 32 } 33 else 34 { 35 printf(" "); 36 } 37 } 38 return 0; 39 } 40 int prime(int p) 41 { 42 int ret; 43 if (p <= 1) 44 { 45 ret = 0; 46 } 47 else 48 { 49 ret = 1; 50 for (int i = 2; i < p; i++) 51 { 52 if (p % i == 0) 53 { 54 ret = 0; 55 break; 56 } 57 } 58 } 59 60 return ret; 61 } 62 void Goldbach(int n) 63 { 64 for (int i = 2; i <= n / 2; i++) 65 { 66 if (prime(i) * prime(n - i)) 67 { 68 printf("%d=%d+%d", n, i, n - i); 69 break; 70 } 71 } 72 }