{"id":611,"date":"2017-01-24T17:40:52","date_gmt":"2017-01-25T01:40:52","guid":{"rendered":"http:\/\/www.cornerspots.com\/sirknightj\/?p=611"},"modified":"2017-06-26T08:15:54","modified_gmt":"2017-06-26T16:15:54","slug":"first-10-million-prime-numbers","status":"publish","type":"post","link":"https:\/\/www.sirknightj.com\/blog\/2017\/01\/24\/first-10-million-prime-numbers\/","title":{"rendered":"First 10 Million Prime Numbers"},"content":{"rendered":"<p>I&#8217;ve decided to increase the number from 1,000,000 to 10,000,000.<\/p>\n<p><!--more--><\/p>\n<p>Surprisingly, this took more than 2.5 hours to calculate.<\/p>\n<p>Also, it takes a long time to open the notepad file, for some reason.<\/p>\n<p>Here&#8217;s my code again, in case you wanted to look at it:<\/p>\n<pre><code>\r\nimport math\r\ntext_file = open(\"Output.txt\", \"w\")\r\n\r\nprimes = [2, 3]\r\nprint(\"This file was made for cornerspots.com\\n1. 2\\n2. 3\")\r\ntext_file.write(\"This file was made for cornerspots.com\\n2\\n\")\r\nnumber = 1\r\nrowNumber = 2\r\n\r\nwhile rowNumber < 10000000:\r\n    isPrime = True\r\n    number += 2\r\n\r\n    for prime in primes:\r\n        # if number is bigger than the sqrt of num we're checking\r\n        if prime > math.sqrt(number):\r\n            break\r\n        # is not a prime\r\n        if number % prime == 0:\r\n            isPrime = False\r\n            break\r\n\r\n    if isPrime:\r\n        rowNumber += 1\r\n        text_file.write(str(number) + \"\\n\")\r\n        primes.append(number)\r\n        print(str(rowNumber) + \". \" + str(number))\r\n\r\ntext_file.close()<\/code><\/pre>\n<p>And here&#8217;s the zip file of my findings:<a href=\"http:\/\/www.sirknightj.com\/blog\/wp-content\/uploads\/2017\/01\/First10MillionPrimeNumbers.zip\">First10MillionPrimeNumbers<\/a><br \/>\nOh, and in case you&#8217;re wondering, the 10,000,000th prime number is 179,424,671.<br \/>\nIf notepad doesn&#8217;t open and instead says not responding, just wait, and it will open eventually. In case notepad doesn&#8217;t work for some reason, try notepad++<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve decided to increase the number from 1,000,000 to 10,000,000.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[7],"tags":[],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.sirknightj.com\/blog\/wp-json\/wp\/v2\/posts\/611"}],"collection":[{"href":"https:\/\/www.sirknightj.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sirknightj.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sirknightj.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sirknightj.com\/blog\/wp-json\/wp\/v2\/comments?post=611"}],"version-history":[{"count":5,"href":"https:\/\/www.sirknightj.com\/blog\/wp-json\/wp\/v2\/posts\/611\/revisions"}],"predecessor-version":[{"id":718,"href":"https:\/\/www.sirknightj.com\/blog\/wp-json\/wp\/v2\/posts\/611\/revisions\/718"}],"wp:attachment":[{"href":"https:\/\/www.sirknightj.com\/blog\/wp-json\/wp\/v2\/media?parent=611"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sirknightj.com\/blog\/wp-json\/wp\/v2\/categories?post=611"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sirknightj.com\/blog\/wp-json\/wp\/v2\/tags?post=611"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}