{"id":929,"date":"2012-06-25T13:42:34","date_gmt":"2012-06-25T05:42:34","guid":{"rendered":"http:\/\/www.hsyyf.me\/?p=929"},"modified":"2012-06-25T13:43:21","modified_gmt":"2012-06-25T05:43:21","slug":"project-euler-3","status":"publish","type":"post","link":"https:\/\/www.hsyyf.me\/?p=929","title":{"rendered":"Project Euler 3"},"content":{"rendered":"<p>\u4eca\u5929\u662f\u7b2c\u4e09\u9898\u2014\u2014<\/p>\n<p>The prime factors of 13195 are 5, 7, 13 and 29.<\/p>\n<p>What is the largest prime factor of the number 600851475143 ?<\/p>\n<p>\u4eca\u5929\u8fd9\u9053\u9898\u975e\u5e38\u6709\u610f\u601d\uff0c\u5c31\u662f\u6c42600851475143\u7684\u6700\u5927\u8d28\u56e0\u6570\u3002\u9898\u76ee\u5f88\u7b80\u5355\u4f5c\u4e3a\u4e00\u9053\u7f16\u7a0b\u9898\u53ef\u4ee5\u8bf4\u662f\u975e\u5e38\u57fa\u7840\uff0c\u53ea\u8981\u6709\u6700\u57fa\u672c\u7684\u7f16\u7a0b\u601d\u60f3\u90fd\u80fd\u5f88\u5feb\u7684\u89e3\u51fa\u6765\u3002\u7136\u800c\uff0c\u8fd9\u9053\u9898\u7565\u6709\u9677\u9631\u7684\u662f\u8fd9\u4e2a\u6570\u957f\u5ea6\u8fc7\u5927\uff0c\u5bf9\u4e8e32\u4f4d\u7684C\uff0c\u666e\u901a\u7684INT\u548cLONG\u6ca1\u6709\u529e\u6cd5\u5904\u7406\u3002\u8fd9\u65f6\u60f3\u5230\u6700\u7b80\u5355\u7684\u5904\u7406\u65b9\u6cd5\u662f\u7528python\uff0c\u4e0d\u53d7\u4f4d\u6570\u7684\u9650\u5236\u3002<\/p>\n<p>\u5176\u6b21\uff0c\u8fd9\u9053\u9898\u7684\u53e6\u4e00\u5904\u9677\u9631\u662f\u5982\u4f55\u6700\u5feb\u7684\u627e\u51fa\u6700\u5927\u8d28\u56e0\u6570\u3002\u4e4d\u4e00\u770b\u8fd9\u4e2a\u6570\u5f88\u5927\uff0c\u5f00\u5e73\u65b9\u4e4b\u540e\u662f7\u4e07\u591a\uff0c\u7b2c\u4e00\u60f3\u6cd5\u662f\u4ece\u5927\u5f80\u5c0f\u4e86\u7b5b\u9009\u3002\u4f46\u662f\u7b97\u51fa\u6765\u4e4b\u540e\u53d1\u73b0\uff0c\u5176\u5b9e\u8fd9\u4e2a\u7ed3\u679c\u5e76\u4e0d\u5927\uff0c\u4ece2\u5f00\u59cb\u7b5b\u9009\u53cd\u800c\u65b9\u4fbf\u3002<\/p>\n<p>\u7b2c\u4e00\u6b21\u7b97\u7684\u65f6\u5019\u6ca1\u6709\u6ce8\u610f\u7b2c\u4e8c\u4e2a\u95ee\u9898\uff0cpython\u7684\u8ba1\u7b97\u91cf\u5e76\u4e0d\u5c0f\uff0c\u4e0d\u8fc7\u8ba1\u7b97\u901f\u5ea6\u8fd8\u662f\u51fa\u4e4e\u610f\u6599\uff0c\u5f88\u5feb\u5c31\u51fa\u7ed3\u679c\u4e86\u3002\u770b\u6765python\u7684\u6548\u7387\u8fd8\u662f\u6709\u6f5c\u529b\u7684\u3002<\/p>\n<p>python\u4ece\u5927\u5f80\u5c0f\u7b5b\u9009\u7684\u5b9e\u73b0\u2014\u2014<br \/>\n<code lang=\"python\">#========================================================================<br \/>\n#   FileName: Project.py<br \/>\n#     Author: hsyyf<br \/>\n#      Email: 931107419@qq.com<br \/>\n#   HomePage: http:\/\/www.hsyyf.me<br \/>\n# LastChange: 2012-06-25 13:23:04<br \/>\n#========================================================================<br \/>\ndef fun(m):<br \/>\n    k=int(math.sqrt(m))<br \/>\n    for i in range(2,k):<br \/>\n        if m%i==0:<br \/>\n            return 0<br \/>\n    return 1<\/p>\n<p>import math<br \/>\nN=600851475143<br \/>\nm=int(math.sqrt(N))<br \/>\nfor i in range(m,2,-1):<br \/>\n    if N%i==0:<br \/>\n        if fun(i):<br \/>\n            break<\/p>\n<p>print(i)<br \/>\n<\/code><\/p>\n<p>\u7ed3\u679c\u4e3a6857.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u662f\u7b2c\u4e09\u9898\u2014\u2014 The prime factors of 13195 are 5, 7, 13 and 29 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[16],"tags":[127],"class_list":["post-929","post","type-post","status-publish","format-standard","hentry","category-16","tag-project-euler"],"_links":{"self":[{"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=\/wp\/v2\/posts\/929","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=929"}],"version-history":[{"count":0,"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=\/wp\/v2\/posts\/929\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}