{"id":960,"date":"2017-08-01T11:01:05","date_gmt":"2017-08-01T15:01:05","guid":{"rendered":"https:\/\/www.joshho.com\/blog\/?p=960"},"modified":"2017-08-01T12:29:00","modified_gmt":"2017-08-01T16:29:00","slug":"project-euler-problem-3","status":"publish","type":"post","link":"https:\/\/www.joshho.com\/blog\/2017\/08\/01\/project-euler-problem-3\/","title":{"rendered":"Project Euler &#8211; Problem 3"},"content":{"rendered":"<p>Problem 3:<br \/>\nThe prime factors of 13195 are 5, 7, 13 and 29.<\/p>\n<p>What is the largest prime factor of the number 600851475143 ?<br \/>\n<code><\/p>\n<pre lang='python'>\r\nimport math\r\n\r\npSieve = []\r\nmax = math.floor(math.sqrt( 600851475143 ))\r\nl = 0\r\ni=2;\r\nwhile i<max:\r\n\tii = math.floor(math.sqrt( i ))\r\n\tfound = False\r\n\tj=0\r\n\twhile j<len(pSieve):\r\n\t\tif ( pSieve[j] > ii ):\r\n\t\t\tbreak;\r\n\t\tif (i % pSieve[j] == 0): \r\n\t\t\tfound = True\r\n\t\t\tbreak;\r\n\t\tj+=1\r\n\tif found == False:\r\n\t\tpSieve.append(i)\r\n\t\tif (600851475143 % i == 0):\r\n\t\t\tl=i\r\n\ti+=1\r\nprint l\r\n<\/pre>\n<p><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem 3:<br \/>\nThe prime factors of 13195 are 5, 7, 13 and 29.<\/p>\n<p>What is the largest prime factor of the number 600851475143 ?<br \/>\n<code><\/p>\n<pre lang='python'>\r\nimport math\r\n\r\npSieve = []\r\nmax = math.floor(math.sqrt( 600851475143 ))\r\nl = 0\r\ni=2;\r\nwhile i<max:\r\n\tii = math.floor(math.sqrt( i ))\r\n\tfound = False\r\n\tj=0\r\n\twhile j<len(pSieve):\r\n\t\tif ( pSieve[j] > ii ):\r\n\t\t\tbreak;\r\n\t\tif (i % pSieve[j] == 0): \r\n\t\t\tfound = True\r\n\t\t\tbreak;\r\n\t\tj+=1\r\n\tif found == False:\r\n\t\tpSieve.append(i)\r\n\t\tif (600851475143 % i == 0):\r\n\t\t\tl=i\r\n\ti+=1\r\nprint l\r\n<\/pre>\n<p><\/code><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[56],"tags":[],"_links":{"self":[{"href":"https:\/\/www.joshho.com\/blog\/wp-json\/wp\/v2\/posts\/960"}],"collection":[{"href":"https:\/\/www.joshho.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.joshho.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.joshho.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.joshho.com\/blog\/wp-json\/wp\/v2\/comments?post=960"}],"version-history":[{"count":0,"href":"https:\/\/www.joshho.com\/blog\/wp-json\/wp\/v2\/posts\/960\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.joshho.com\/blog\/wp-json\/wp\/v2\/media?parent=960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.joshho.com\/blog\/wp-json\/wp\/v2\/categories?post=960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.joshho.com\/blog\/wp-json\/wp\/v2\/tags?post=960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}