{"id":14312,"date":"2021-08-02T05:11:41","date_gmt":"2021-08-02T05:11:41","guid":{"rendered":"https:\/\/club.informatix.co.jp\/?p=14312"},"modified":"2024-04-30T05:51:04","modified_gmt":"2024-04-30T05:51:04","slug":"python%e3%81%a7%e7%b4%a0%e6%95%b0%e5%ae%9a%e7%90%86%ef%bd%9cpython%e3%81%a7%e6%95%b0%e5%ad%a6%e3%82%92%e5%ad%a6%e3%81%bc%e3%81%86%ef%bc%81%e3%80%80%e7%ac%ac11%e5%9b%9e","status":"publish","type":"post","link":"https:\/\/club.informatix.co.jp\/?p=14312","title":{"rendered":"Python\u3067\u7d20\u6570\u5b9a\u7406\uff5cPython\u3067\u6570\u5b66\u3092\u5b66\u307c\u3046\uff01 \u7b2c11\u56de"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">\u76ee\u6b21<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69e46087bf166\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69e46087bf166\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/club.informatix.co.jp\/?p=14312\/#%E3%81%AF%E3%81%98%E3%82%81%E3%81%AB\" >\u306f\u3058\u3081\u306b<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/club.informatix.co.jp\/?p=14312\/#%E3%83%AC%E3%83%9D%E3%83%BC%E3%83%88\" >\u30ec\u30dd\u30fc\u30c8<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/club.informatix.co.jp\/?p=14312\/#%E7%B4%A0%E6%95%B0%E5%AE%9A%E7%90%86\" >\u7d20\u6570\u5b9a\u7406<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/club.informatix.co.jp\/?p=14312\/#%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%80%8Cprimetheorem1py%E3%80%8D\" >\u30d7\u30ed\u30b0\u30e9\u30e0\u300cprimetheorem1.py\u300d<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/club.informatix.co.jp\/?p=14312\/#%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%80%8Cprimetheorem2py%E3%80%8D\" >\u30d7\u30ed\u30b0\u30e9\u30e0\u300cprimetheorem2.py\u300d<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/club.informatix.co.jp\/?p=14312\/#%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%80%8Cprimetheorem3py%E3%80%8D\" >\u30d7\u30ed\u30b0\u30e9\u30e0\u300cprimetheorem3.py\u300d<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n<h2><span class=\"ez-toc-section\" id=\"%E3%81%AF%E3%81%98%E3%82%81%E3%81%AB\"><\/span>\u306f\u3058\u3081\u306b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"%E3%83%AC%E3%83%9D%E3%83%BC%E3%83%88\"><\/span>\u30ec\u30dd\u30fc\u30c8<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u6bce\u6708\u958b\u50ac\u4e2d\u306eZoom\u30aa\u30f3\u30e9\u30a4\u30f3\u6388\u696d\u3001\u685c\u4e95\u9032\u306e\u7b97\u6570\u30fb\u6570\u5b66\u6559\u5ba4<\/p>\n<ul>\n<li>\u685c\u4e95\u9032\u306e\u9b54\u6cd5\u306e\u7b97\u6570\u6559\u5ba4<\/li>\n<li>\u685c\u4e95\u9032\u306e\u6570\u5b66\u6d6a\u6f2b\u7d00\u884c<\/li>\n<li>\u685c\u4e95\u9032\u306ePython\u30fbUNIX\u6559\u5ba4\uff08\u5165\u9580\u30b3\u30fc\u30b9\u5168\uff13\u56de\uff09<\/li>\n<li>\u685c\u4e95\u9032\u306ePython\u30fbUNIX\u30fbMath\u6559\u5ba4\uff08\u5fdc\u7528\u30b3\u30fc\u30b9\uff09<\/li>\n<\/ul>\n<p>\u685c\u4e95\u9032\u306ePython\u30fbUNIX\u6559\u5ba4\u3092\u9664\u304f3\u30af\u30e9\u30b9\u306e7\u6708\u5171\u901a\u304c\u5bfe\u6570\u3067\u3057\u305f\u3002\u30bf\u30a4\u30c8\u30eb\u306f\u9806\u306b<\/p>\n<ul>\n<li>\u5c0f\u5b66\u751f\u304b\u3089\u306f\u3058\u3081\u3088\u3046\uff01\u5bfe\u6570<\/li>\n<li>\u5c0f\u6570\u70b9\u300c.\u300d\u8a95\u751f402\u5e74\u8a18\u5ff5\u3000\u5bfe\u6570<\/li>\n<li>Python\u3067\u7d20\u6570\u3000\u7d20\u6570\u5b9a\u7406<\/li>\n<\/ul>\n<p>\u3067\u3057\u305f\u3002<\/p>\n<p>\u685c\u4e95\u9032\u306ePython\u30fbUNIX\u30fbMath\u6559\u5ba4\uff08\u5fdc\u7528\u30b3\u30fc\u30b9\uff09\u306e\u300cPython\u3067\u7d20\u6570\u3000\u7d20\u6570\u5b9a\u7406\u300d\u306b\u306f\u5bfe\u6570\u304c\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u7d20\u6570\u5b9a\u7406\u304c\u5bfe\u6570\u305d\u306e\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>9\u6b73\u306e\u5c0f\u5b66\u751f\u304b\u308960\u6b73\u904e\u304e\u307e\u3067\u306e\u65b9\u306b\u53c2\u52a0\u3044\u305f\u3060\u304d\u3001Python\u306e\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3068\u3068\u3082\u306b\u7d20\u6570\u5b9a\u7406\u3092\u81ea\u5206\u306e\u624b\u3068\u76ee\u3068\u982d\u3067\u691c\u8a3c\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u6b21\u306e\u7d50\u679c\u306f\u3001\u81ea\u7136\u6570\u309210\u306e10\u4e57\u307e\u3067\u306e\u7d20\u6570\u306e\u500b\u6570\u3068\u7d20\u6570\u5b9a\u7406\u3092\u6bd4\u8f03\u3057\u305f\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>2\u3064\u306e\u6bd4\u304c1\u306b\u8fd1\u3065\u304f\u3053\u3068\u304c\u5206\u304b\u308a\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-14318\" src=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-1.jpg\" alt=\"\" width=\"800\" height=\"523\" srcset=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-1.jpg 800w, https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-1-300x196.jpg 300w, https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-1-768x502.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E7%B4%A0%E6%95%B0%E5%AE%9A%E7%90%86\"><\/span>\u7d20\u6570\u5b9a\u7406<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u7d20\u6570\u5b9a\u7406\u306f\u4eca\u304b\u3089250\u5e74\u4ee5\u4e0a\u524d\u30011760\u5e74\u306b<a href=\"https:\/\/club.informatix.co.jp\/?p=3060\" target=\"_blank\" rel=\"noopener\">\u30aa\u30a4\u30e9\u30fc<\/a>\u306b\u3088\u3063\u3066\u767a\u898b\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u30aa\u30a4\u30e9\u30fc\u4ee5\u964d\u3082<a href=\"https:\/\/club.informatix.co.jp\/?p=2508\" target=\"_blank\" rel=\"noopener\">\u30ac\u30a6\u30b9<\/a>\u3001\u30eb\u30b8\u30e3\u30f3\u30c9\u30eb\u3001\u30c7\u30a3\u30ea\u30af\u30ec\u3001\u30c1\u30a7\u30d3\u30b7\u30a7\u30d5\u3068\u3044\u3063\u305f\u6570\u5b66\u8005\u305f\u3061\u306e\u624b\u306b\u3088\u3063\u3066\u767a\u898b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4e2d\u3067\u3082\u30ac\u30a6\u30b9\u306e\u767a\u898b\u7269\u8a9e\u306f\u3088\u304f\u77e5\u3089\u308c\u3066\u3044\u307e\u3059\u300215\u6b73\u306e\u30ac\u30a6\u30b9\u306f300\u4e07\u307e\u3067\u306e\u4e2d\u306b\u3042\u308b\u7d20\u6570\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\u3057\u3001\u5bdd\u308b\u524d\u306b\u7d20\u6570\u30ea\u30b9\u30c8\u3092\u773a\u3081\u308b\u3053\u3068\u3092\u7fd2\u6163\u306b\u3057\u3066\u3044\u305f\u3068\u3044\u3044\u307e\u3059\u3002<\/p>\n<p>\u30ac\u30a6\u30b9\u304c\u7d20\u6570\u30ea\u30b9\u30c8\u3068\u3068\u3082\u306b\u773a\u3081\u3066\u3044\u305f\u306e\u304c<a href=\"https:\/\/club.informatix.co.jp\/?p=2864\" target=\"_blank\" rel=\"noopener\">\u81ea\u7136\u5bfe\u6570\u8868<\/a>\u3067\u3059\u3002\u795e\u304c\u304b\u3063\u305f\u8a08\u7b97\u529b\u306b\u3088\u308a\u3001\u30e9\u30f3\u30c0\u30e0\u306b\u51fa\u73fe\u3059\u308b\u7d20\u6570\u306e\u4e2d\u306b\u96a0\u308c\u305f\u6cd5\u5247\u3092\u898b\u3064\u3051\u3060\u3059\u3053\u3068\u306b\u6210\u529f\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>x\u4ee5\u4e0b\u306e\u81ea\u7136\u6570\u306e\u4e2d\u306b\u3042\u308b\u7d20\u6570\u306e\u500b\u6570\u3092\u03c0(x)\u3068\u8868\u3059\u3068\u304d\u3001\u03c0(x)\u306fx\u3092\u5927\u304d\u304f\u3057\u3066\u3044\u304f\u3068x\/log x \u306b\u9650\u308a\u306a\u304f\u8fd1\u3065\u3044\u3066\u3044\u304f\u3068\u3044\u3046\u306e\u304c\u7d20\u6570\u5b9a\u7406\u3067\u3059\u3002<\/p>\n<p>\u30ac\u30a6\u30b9\u304b\u3089100\u5e74\u5f8c\u306e1896\u5e74\u306b\u3001\u30d7\u30fc\u30b5\u30f3\u3068\u30a2\u30c0\u30de\u30fc\u30eb\u304c\u72ec\u7acb\u306b\u8a3c\u660e\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u3057\u305f\u304c\u3063\u3066\u3001x\u4ee5\u4e0b\u306e\u7d20\u6570\u306e\u500b\u6570\u03c0(x)\u3068\u7d20\u6570\u5b9a\u7406\u306b\u3088\u308bx\/log x \u3092\u8a08\u7b97\u3059\u308c\u3070\u7d20\u6570\u5b9a\u7406\u304c\u691c\u8a3c\u3067\u304d\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>log x\u306f<a href=\"https:\/\/club.informatix.co.jp\/?p=2864\" target=\"_blank\" rel=\"noopener\">\u30cd\u30a4\u30d4\u30a2\u6570e<\/a>\uff08=2.718281828459045 \u9b92\u4e00\u9262\u4e8c\u9262\u4e00\u9262\u4e8c\u9262\u81f3\u6975\u7f8e\u5473\u3057\u3044\uff09\u3092\u5e95\u3068\u3059\u308b\u81ea\u7136\u5bfe\u6570\u3067\u3059\u3002<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-14320\" src=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-3.jpg\" alt=\"\" width=\"800\" height=\"500\" srcset=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-3.jpg 800w, https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-3-300x188.jpg 300w, https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-3-768x480.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%80%8Cprimetheorem1py%E3%80%8D\"><\/span>\u30d7\u30ed\u30b0\u30e9\u30e0\u300cprimetheorem1.py\u300d<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>&gt;&gt;&gt; \u3000# \u7d20\u6570\u5b9a\u7406<br \/>\n&gt;&gt;&gt; \u3000# \u30a8\u30e9\u30c8\u30b9\u30c6\u30cd\u30b9\u306e\u7be9\uff08\u3075\u308b\u3044\uff09\u306b\u3088\u308a\u7d20\u6570\u3092\u30ea\u30b9\u30c8\u30a2\u30c3\u30d7<br \/>\n&gt;&gt;&gt; \u3000import math<br \/>\n&gt;&gt;&gt; \u3000n =int(input(&#8220;10\u306en\u4e57\u4ee5\u4e0b\u306e\u7d20\u6570\u306e\u500b\u6570\u03c0(10^n)\u3092\u8868\u793a\u3002n &gt;&gt; &#8220;))<br \/>\n&gt;&gt;&gt; \u3000p = [i for i in range(10**n + 1)]<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt; \u3000# \u7d20\u6570\u30ea\u30b9\u30c8p[]\u306e\u751f\u6210<br \/>\n&gt;&gt;&gt; \u3000for i in p[3:]:<br \/>\n&gt;&gt;&gt; \u3000\u3000\u3000if p[i] % 2 == 0:<br \/>\n&gt;&gt;&gt; \u3000\u3000\u3000\u3000\u3000p[i] = 0<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt; \u3000root = (10**n) ** 0.5<br \/>\n&gt;&gt;&gt; \u3000for i in range(3, 10**n):<br \/>\n&gt;&gt;&gt; \u3000\u3000\u3000if i &gt; root:<br \/>\n&gt;&gt;&gt; \u3000\u3000\u3000\u3000\u3000break<br \/>\n&gt;&gt;&gt; \u3000\u3000\u3000if p[i] != 0:<br \/>\n&gt;&gt;&gt; \u3000\u3000\u3000\u3000\u3000for j in range(i, 10**n + 1, 2):<br \/>\n&gt;&gt;&gt; \u3000\u3000\u3000\u3000\u3000\u3000\u3000if i * j &gt;= 10**n + 1 :<br \/>\n&gt;&gt;&gt; \u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000break<br \/>\n&gt;&gt;&gt; \u3000\u3000\u3000\u3000\u3000\u3000\u3000p[i * j] = 0<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt; \u3000plist = list(set(p))[2:]<br \/>\n&gt;&gt;&gt; \u3000plistn = str(len(plist))<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt; \u3000print(&#8216; x=&#8217;,10**n)<br \/>\n&gt;&gt;&gt; \u3000print(&#8216; \u03c0(x)=&#8217;,plistn)<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt; \u3000# \u7d20\u6570\u5b9a\u7406\u306e\u8a08\u7b97<br \/>\n&gt;&gt;&gt; \u3000print(f&#8217;x\/log x= {(10**n)\/math.log(10**n):.0f}&#8217;)<br \/>\n&gt;&gt;&gt; \u3000print(f&#8217;2\u3064\u306e\u6bd4= {((10**n)\/math.log(10**n))\/int(plistn):.4f}&#8217;)<\/p>\n<p><a href=\"https:\/\/drive.google.com\/file\/d\/1ISk-CAywu7DyD42I_FINo0bjp7P7adph\/view?usp=sharing\" target=\"_blank\" rel=\"noopener\">\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u306f\u30b3\u30c1\u30e9\u304b\u3089<\/a><\/p>\n<p><a href=\"https:\/\/club.informatix.co.jp\/?p=13457\" target=\"_blank\" rel=\"noopener\">\u7b2c7\u56de\u3067\u7d39\u4ecb\u3057\u305f<\/a>\u30a8\u30e9\u30c8\u30b9\u30c6\u30cd\u30b9\u306e\u7be9\u306e\u30b3\u30fc\u30c9\u3092\u4f7f\u3063\u3066\u7d20\u6570\u30ea\u30b9\u30c8\u3092\u751f\u6210\u3057\u307e\u3059\u3002\u3059\u308b\u3068len()\u95a2\u6570\u3092\u7528\u3044\u3066\u53d6\u5f97\u3057\u305f\u30ea\u30b9\u30c8\u306e\u8981\u7d20\u6570\u304c\u7d20\u6570\u306e\u500b\u6570\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u5927\u304d\u306ax\u306b\u5bfe\u3057\u3066\u8a08\u7b97\u3067\u304d\u308b\u3088\u3046\u306bx\u306b\u306f10\u306en\u4e57\u3092\u4e0e\u3048\u307e\u3059\u3002\u7d20\u6570\u5b9a\u7406\u306e\u8a08\u7b97\u306f\u3001\u81ea\u7136\u5bfe\u6570\u3092math.log()\u95a2\u6570\u3092\u7528\u3044\u3066\u884c\u3044\u307e\u3059\u3002<br \/>\n&gt;&gt;&gt; \u3000print(f&#8217;x\/log x= {(10**n)\/math.log(10**n):.0f}&#8217;)<\/p>\n<p>\u6700\u5f8c\u306b\u30012\u3064\u306e\u6bd4\uff08\u7d20\u6570\u5b9a\u7406\u306e\u5024\/\u672c\u5f53\u306e\u5024\uff09\u3092\u8868\u793a\u3057\u3066\u7d20\u6570\u5b9a\u7406\u3068\u672c\u5f53\u306e\u5024\u3092\u6bd4\u8f03\u3057\u307e\u3059\u3002<\/p>\n<p>\u7d50\u679c\u306f\u6b21\u306e\u3088\u3046\u306b\u51fa\u529b\u3055\u308c\u307e\u3059\u300210\u4e07\u307e\u3067\u306b\u7d20\u6570\u306f9592\u500b\u3042\u308a\u307e\u3059\u304c\u3001\u7d20\u6570\u5b9a\u7406\u3067\u306f8686\u500b\uff08\u672c\u5f53\u306e\u5024\u306e\u7d0490%\uff09\u3068\u7b97\u51fa\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-14321\" src=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-4.jpg\" alt=\"\" width=\"543\" height=\"157\" srcset=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-4.jpg 543w, https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-4-300x87.jpg 300w\" sizes=\"(max-width: 543px) 100vw, 543px\" \/><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%80%8Cprimetheorem2py%E3%80%8D\"><\/span>\u30d7\u30ed\u30b0\u30e9\u30e0\u300cprimetheorem2.py\u300d<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>&gt;&gt;&gt; \u3000# \u7d20\u6570\u5b9a\u7406<br \/>\n&gt;&gt;&gt; \u3000# \u4ee3\u6570\u30e9\u30a4\u30d6\u30e9\u30eaSymPy\u306e\u95a2\u6570primepi(n) n\u4ee5\u4e0b\u306e\u7d20\u6570\u306e\u500b\u6570<br \/>\n&gt;&gt;&gt; \u3000import math<br \/>\n&gt;&gt;&gt; \u3000import numpy as np<br \/>\n&gt;&gt;&gt; \u3000from sympy import primepi<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt; \u3000n = int(input(&#8220;10\u306en\u4e57\u4ee5\u4e0b\u306e\u7d20\u6570\u306e\u500b\u6570\u03c0(10^n)\u3092\u8868\u793a\uff08\u9ad8\u901f\uff09\u3002n &gt;&gt; &#8220;))<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt; \u3000for i in range(1, n+1):<br \/>\n&gt;&gt;&gt; \u3000\u3000print(&#8216; x=&#8217;,10**i)<br \/>\n&gt;&gt;&gt; \u3000\u3000print(&#8216; \u03c0(x)=&#8217;,primepi(10**i))<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt; \u3000\u3000# \u7d20\u6570\u5b9a\u7406\u306e\u8a08\u7b97<br \/>\n&gt;&gt;&gt; \u3000\u3000print(f&#8217;x\/log x= {(10**i)\/math.log(10**i):.0f}&#8217;)<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt; \u3000\u3000print(f&#8217;2\u3064\u306e\u6bd4= {((10**i)\/math.log(10**i))\/primepi(10**i):.4f}&#8217;)<br \/>\n&gt;&gt;&gt; print()<\/p>\n<p><a href=\"https:\/\/drive.google.com\/file\/d\/1ZHXoWOBZOnJ_1DWDjmsR-Oaud3eFiypv\/view?usp=sharing\" target=\"_blank\" rel=\"noopener\">\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u306f\u30b3\u30c1\u30e9\u304b\u3089<\/a><\/p>\n<p>\u30a8\u30e9\u30c8\u30b9\u30c6\u30cd\u30b9\u306e\u7be9\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u7d20\u6570\u30ea\u30b9\u30c8\u3092\u751f\u6210\u3059\u308b\u306b\u306f\u9650\u754c\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u4ee3\u6570\u30e9\u30a4\u30d6\u30e9\u30eaSymPy\u306e\u95a2\u6570primepi()\u3092\u7528\u3044\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>primepi(n)\u306b\u3088\u308a\u307e\u3055\u306b\u03c0(n)\uff1dn\u4ee5\u4e0b\u306e\u7d20\u6570\u306e\u500b\u6570\u3092\u8fd4\u3057\u307e\u3059\u3002\u672c\u8cea\u7684\u306bprimetheorem1.py\u3068\u7570\u306a\u308b\u306e\u306f\u3053\u3053\u3060\u3051\u3067\u3059\u3002<\/p>\n<p>\u7d50\u679c\u306f\u6b21\u306e\u3088\u3046\u306b\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>n\u306b5\u3068\u4e0e\u3048\u308c\u3070\u300110\u3001100\u30011000\u300110000\u3001100000\u306b\u5bfe\u3059\u308b\u03c0(n) =primepi(n)\u3068\u7d20\u6570\u5b9a\u7406\u306e\u5024\u3001\u304a\u3088\u30732\u3064\u306e\u6bd4\u3092\u51fa\u529b\u3057\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-14322\" src=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-5.jpg\" alt=\"\" width=\"638\" height=\"664\" srcset=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-5.jpg 638w, https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-5-288x300.jpg 288w\" sizes=\"(max-width: 638px) 100vw, 638px\" \/><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%80%8Cprimetheorem3py%E3%80%8D\"><\/span>\u30d7\u30ed\u30b0\u30e9\u30e0\u300cprimetheorem3.py\u300d<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>&gt;&gt;&gt; \u3000# \u7d20\u6570\u5b9a\u7406<br \/>\n&gt;&gt;&gt; \u3000# \u4ee3\u6570\u30e9\u30a4\u30d6\u30e9\u30eaSymPy\u306e\u95a2\u6570prime(n) n\u756a\u76ee\u306e\u7d20\u6570<br \/>\n&gt;&gt;&gt; \u3000import math<br \/>\n&gt;&gt;&gt; \u3000from sympy import prime<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt; \u3000n = eval(input(&#8220;n\u756a\u76ee\u306e\u7d20\u6570p(n)\u3092\u8a08\u7b97\u3057\u3088\u3046\u3002n &gt;&gt; &#8220;))<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt; \u3000p1 = int(n*math.log(n)) # n\u756a\u76ee\u306e\u7d20\u6570\u306e\u8fd1\u4f3c\u5f0f<br \/>\n&gt;&gt;&gt; \u3000p2 = prime(n) # n\u756a\u76ee\u306e\u7d20\u6570<br \/>\n&gt;&gt;&gt; \u3000e = ((p2-p1)\/p2)*100 # \u8aa4\u5dee<br \/>\n&gt;&gt;&gt; \u3000print(f&#8217;p({n})\u2252&#8217;, p1, &#8216;\u7d20\u6570\u5b9a\u7406\u306e\u8fd1\u4f3c\u5f0f&#8217;)<br \/>\n&gt;&gt;&gt; \u3000print(f&#8217;p({n})=&#8217;, p2, &#8216;\u672c\u5f53\u306e\u5024&#8217;)<br \/>\n&gt;&gt;&gt; \u3000print(f&#8217;\u8aa4\u5dee{e:.2f}%&#8217;)<\/p>\n<p><a href=\"https:\/\/drive.google.com\/file\/d\/1oVqe_VD8Dp9mUR-AzO1W2FRIaNifkgXL\/view?usp=sharing\" target=\"_blank\" rel=\"noopener\">\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u306f\u30b3\u30c1\u30e9\u304b\u3089<\/a><\/p>\n<p>\u4ee3\u6570\u30e9\u30a4\u30d6\u30e9\u30eaSymPy\u306b\u306fn\u756a\u76ee\u306e\u7d20\u6570\u3092\u4e0e\u3048\u308b\u95a2\u6570prime(n)\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u305d\u308c\u3092\u7528\u3057\u3066\u3001\u7d20\u6570\u5b9a\u7406\u306e\u5f0f\u304b\u3089\u5c0e\u304b\u308c\u308bn\u756a\u76ee\u306e\u7d20\u6570p(n)\u306e\u8fd1\u4f3c\u5f0f\u3068\u306e\u6bd4\u8f03\u3082\u884c\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-14317\" src=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-7.jpg\" alt=\"\" width=\"800\" height=\"88\" srcset=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-7.jpg 800w, https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-7-300x33.jpg 300w, https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-7-768x84.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>\u6b21\u306e\u7d50\u679c\u306f100000\u756a\u76ee\u306e\u7d20\u6570p(100000)\u306e\u6bd4\u8f03\u3067\u3059\u3002\u3053\u308c\u3082\u7d20\u6570\u5b9a\u7406\u3068\u540c\u69d8\u3001n\u304c\u5927\u304d\u304f\u306a\u308c\u30702\u3064\u306e\u8aa4\u5dee\u304c0\u306b\u8fd1\u3065\u304d\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-14323\" src=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-6.jpg\" alt=\"\" width=\"504\" height=\"131\" srcset=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-6.jpg 504w, https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-6-300x78.jpg 300w\" sizes=\"(max-width: 504px) 100vw, 504px\" \/> <img decoding=\"async\" class=\"aligncenter size-full wp-image-14319\" src=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-2.jpg\" alt=\"\" width=\"800\" height=\"530\" srcset=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-2.jpg 800w, https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-2-300x199.jpg 300w, https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-2-768x509.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>\u7686\u3055\u3093\u3082\u3001\u305c\u3072Python\u3092\u4f7f\u3063\u3066\u7d20\u6570\u5b9a\u7406\u3092\u81ea\u5206\u306e\u76ee\u3067\u78ba\u304b\u3081\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u306b \u30ec\u30dd\u30fc\u30c8 \u6bce\u6708\u958b\u50ac\u4e2d\u306eZoom\u30aa\u30f3\u30e9\u30a4\u30f3\u6388\u696d\u3001\u685c\u4e95\u9032\u306e\u7b97\u6570\u30fb\u6570\u5b66\u6559\u5ba4 \u685c\u4e95\u9032\u306e\u9b54\u6cd5\u306e\u7b97\u6570\u6559\u5ba4 \u685c\u4e95\u9032\u306e\u6570\u5b66\u6d6a\u6f2b\u7d00\u884c \u685c\u4e95\u9032\u306ePython\u30fbUNIX\u6559\u5ba4\uff08\u5165\u9580\u30b3\u30fc\u30b9\u5168\uff13\u56de\uff09 \u685c\u4e95\u9032\u306ePytho &#8230; <\/p>\n","protected":false},"author":4,"featured_media":14320,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,464,526],"tags":[65,380],"class_list":["post-14312","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-4","category-hito-star-mathmatics","category-526","tag-python","tag-380"],"jetpack_featured_media_url":"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2021\/08\/20210802-3.jpg","_links":{"self":[{"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/14312","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14312"}],"version-history":[{"count":15,"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/14312\/revisions"}],"predecessor-version":[{"id":19947,"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/14312\/revisions\/19947"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=\/wp\/v2\/media\/14320"}],"wp:attachment":[{"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}