哥德巴赫猜想证明(C语言实现50以内的正偶数证明)

《一》哥德巴赫猜想内容:

        一个充分大的偶数(大于或等于6)可以分解为两个素数之和。

《二》实现要点:

        要点:

               判断素数(质数):除了1和本身没有其他约数。

                最小的质数:2

       判断要点:

               偶数n,存在n=i+(n-i);

               其中,i 与 n-1 都是质数;

               满足以上条件,n满足哥德巴赫猜想。

《三》C语言简单实现:

             

               

 1 #define _CRT_SECURE_NO_WARNINGS
 2 #include <stdio.h>
 3 #include <stdlib.h>
 4 #include <math.h>
 5 
 6 
 7 int nisprimer(int n)
 8 {
 9     if (n <= 2)
10     {
11         return 0;
12     }
13     else
14     {
15         int i = 2;
16         while(i<sqrt(n)&&n%i != 0)
17         {
18             i++;
19         }
20         if (n%i == 0)
21         {
22             return 0;
23         }
24         else
25         {
26             return 1;
27         }
28     }
29     
30 }
31 
32 int main()
33 {
34     for (int i = 6; i < 50; i += 2)
35     {
36         for (int j = 2; j <= i/2; j++)
37         {
38             if (nisprimer(j) && nisprimer(i - j))
39             {
40                 printf("i=%d,%d=%d+%d
",i,i,j,i-j);
41             }
42         }
43     }
44 
45     system("pause");
46 }
View Code

              

原文地址:https://www.cnblogs.com/weiyikang/p/5036029.html