「素数表作成プログラム」をどんな風に作ったか、解説をご覧になるには prime3.htm

PRIME 素数を数える。

左端の数値を中心に、Span 幅で、素数の個数を数えています。左上隅のデータでは、10万を中心に、010万の範囲に 9,592個、10万〜20万の範囲に 8,392 素数があります。併せて、17,984個あります。次の段は、90~100万に7,224個、100~110万に7,216個で併せて14,440個あり、0~100万には78,498個、100~200万が70,435個で、併せて148,933個ある と読みます。プリントアウトするには、下のほうをご覧下さい。

PRIME             Span = 2.0E+05

1.E+05   9,592                                Span = 2.0E+06

              8,392     17,984

1.E+06   7,224                   78,498                               Span = 2.0E+07

              7,216     14,440 70,435   148,933

1.E+07   6,134                   62,090                 664,579                                    Span = 2.0E+08

              6,241     12,375 61,938   124,028 606,028 1,270,607

1.E+08   5,454                   54,332                 544,501                 5,761,455                                Span = 2.0E+09

              5,411     10,865 54,208   108,540 541,854 1,086,355 5,317,482 11,078,937         

1.E+09   4,832                   47,957                 482,825                 4,838,319                    50,847,534                                    Span = 2.0E+10

              4,832     9,664     48,155   96,112   482,449 965,274  4,814,936 9,653,255 47,374,753 98,222,287

1.E+10   4,306                   43,453                 434,425                 4,343,734                    43,529,316                      455,052,511

              4,306     8,612     43,427   86,880   434,650 869,075 4,341,930 8,685,664 43,336,106 86,865,422  427,145,205 882,197,716

1.E+11   3,911                   39,331                 394,921                                                                     

              4,019     7,930     39,434   78,765   394,401 789,322

1.E+12   3,613                   36,400                 362,479

              3,614     7,227     36,249   72,649   361,726 724,205

 

ここまでのデータは正しいと思っています。(1+1 付近までのチェックで)

後続のデータは残念ながら間違いで、近似値に過ぎません。検索テーブルのサイズが100万で、1兆を超えると少しずつ誤差が出てきます。03/12/08 追記。

 

1.E+13   3,250                   33,226                 334,199

              3,382     6,632     33,456   66,682   334,312 668,511

1.E+14   3,079                   31,115                 310,457

              3,045     6,124     30,892   62,007   310,582 621,039

1.E+15   2,857                   28,910

              2,805     5,662     28,845   57,755

1.E+16   2,710                   27,133

              2,697     5,407     27,168   54,301

1.E+17   2,428                   25,437

              2,515     4,943     25,463   50,900                                                                                                                                                           

 

数学セミナー 2001/7 P.23 に於ける、山村 先生の記述の中に、コンピューター利用で、π(1010) = 455052511 とあります。当方のプログラム(P305.exe, P3051.exe)で、start = 0, end = 9999 とすると、手持ちのパソコンで、数分後(My Machineで実測してみたら、119秒でした)に同じ結果が得られます。この結果から、エラトステネスの篩は、少なくとも100億まではまともに動いているようです。

 

ここからは、Excel へ読み込ませるための部分で、内容は、上記と同じです。PRIME以降のコピーをとったら、構わずExcel へ貼り付けてから考えてください。Excel に慣れた人ならPrime1.htmを参考にして簡単に印刷書式が作れます。

――――――――――――――――――――――――――――――――――――――――――

PRIME  Span = 2.0E+05                                                                                                                                                                                                                                 

                                                                                    左端の、数値を中心に、Span 幅で、素数の個数を数えています。                                                                                                                                                                       

1.E+05   9,592                                 Span = 2.0E+06                              左上隅のデータでは、10万を中心に、010万の範囲に 9,592個、10万〜20万の範囲に 8,392 素数があります。                                                                                                                                            

              8,392     17,984   8.992                                                            併せて、17,984個あって、20万の Span の中で約9%を占めています。                                                                                                                              

1.E+06   7,224                                 78,498                               Span = 2.0E+07                                                                                                                                             

              7,216     14,440   7.220    70,435   148,933 7.447                                                                                                                                                             

1.E+07   6,134                                 62,090                               664,579                             Span = 2.0E+08                                                                                                   

              6,241     12,375   6.188    61,938   124,028 6.201    606,028 1,270,607            6.353                                                                                                                   

1.E+08   5,454                                 54,332                               544,501                             5,761,455                                        Span = 2.0E+09                                                         

              5,411     10,865   5.433    54,208   108,540 5.427    541,854 1,086,355            5.432    5,317,482              11,078,937          5.539                                                                         

1.E+09   4,832                                 47,957                               482,825                             4,838,319                                        50,847,534                                      Span = 2.0E+10               

              4,832     9,664     4.832    48,155   96,112   4.806    482,449 965,274 4.826    4,814,936            9,653,255              4.827    47,374,753          98,222,287          4.911                                

1.E+10   4,306                                 43,453                               434,425                             4,343,734                                        43,529,316                                      455,052,511                     

              4,306     8,612     4.306    43,427   86,880   4.344    434,650 869,075 4.345    4,341,930            8,685,664              4.343    43,336,106          86,865,422          4.343    427,145,205        882,197,716        4.411

1.E+11   3,911                                 39,331                               394,921                                                                                                                                            

              4,019     7,930     3.965    39,434   78,765   3.938    394,401 789,322 3.947                                                                                                                   

1.E+12   3,613                                 36,400                               362,479                                           数学セミナー 2001/7 P.23 に於ける、山村 先生の記述の中に、                                                                                    

              3,614     7,227     3.614    36,249   72,649   3.632    361,726 724,205 3.621                  コンピューター利用で、π(1010) = 455052511 とあります。                                                                                       

1.E+13   3,250                                 33,226                               334,199                                           当方のプログラム(P305.exe, P3051.exe)で、start = 0, end = 9999 とすると、                                                                                     

              3,382     6,632     3.316    33,456   66,682   3.334    334,312 668,511 3.343                 手持ちのパソコンで、数分後(止めたくなった頃)に同じ結果が得られます。                                                                                    

1.E+14   3,079                                 31,115                               310,457                                           この、エラトステネスの篩は、100億までは、まともに動いているようです。                                                                                          

              3,045     6,124     3.062    30,892   62,007   3.100    310,582 621,039 3.105                                                                                                                   

1.E+15   2,857                                 28,910                                                                                                                                                                                        

              2,805     5,662     2.831    28,845   57,755   2.888                                                                                                                                                             

1.E+16   2,710                                 27,133                                                                                                                                                                                        

              2,697     5,407     2.704    27,168   54,301   2.715                                                                                                                                                             

1.E+17   2,428                                 25,437                                                                                                                                                                                        

              2,515     4,943     2.472    25,463   50,900   2.545