使用C程式驗證歌德巴哈猜想

來源:互聯網
上載者:User

標籤:style   blog   color   io   使用   for   div   sp   log   

就是一個足夠大的偶數可以寫成兩個素數的和

 1 #include<stdio.h> 2 #include<math.h> 3  4 int main(void) 5 { 6     int i,j; 7     int num=30284;   //任意大於6的偶數 8     int p,q; 9     int flagp,flagq;10 11     p=1;12     do13     {14         p=p+1;15         q=num-p;16         flagp=1;17         flagq=1;18 19         for(i=2;i<sqrt((double)p);++i)20         {21             if(p%i==0)22             {23                 flagp=0;24                 break;25             }26         }27 28         j=2;29         while(j<sqrt((double)q))30         {31             if(q%j==0)32             {33                 flagq=0;34                 break;35             }36             ++j;37         }38     }while(flagq*flagq==0);39 40     printf("%d = %d + %d \n",num,p,q);41     return 0;42 }

 思路就是從p=1開始計算,是否將大數分解後的兩個數p,q都是素數,是就輸出,不是的話就+1繼續進行運算

使用C程式驗證歌德巴哈猜想

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.