{"id":87,"date":"2013-01-17T21:04:54","date_gmt":"2013-01-18T05:04:54","guid":{"rendered":"http:\/\/willclausen.com\/?p=87"},"modified":"2013-01-17T21:04:54","modified_gmt":"2013-01-18T05:04:54","slug":"solution-project-euler-problem-2","status":"publish","type":"post","link":"http:\/\/willclausen.com\/?p=87","title":{"rendered":"Solution: Project Euler Problem 2"},"content":{"rendered":"<p>The problem:<\/p>\n<p style=\"padding-left: 30px;\">By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.<\/p>\n<p>My solution (in python):<\/p>\n<pre class=\"brush: python; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n\r\n# Author: Will Clausen\r\n#\r\n# Date: Jan 6, 2013\r\n#\r\n# This program will solve problem 2 in Project\r\n# Euler.\r\n\r\n# This function generates the fibonacci numbers\r\n# under 4,000,000, sums the even ones, and returns\r\n# the sum. Simple.\r\ndef problem2():\r\n\tf1 = 1\r\n\tf2 = 2\r\n\tfn = 0\r\n\tsum = 2\r\n\r\n\twhile fn &lt; 4000000:\r\n\t\tfn = f1 + f2\r\n\t\tf1 = f2\r\n\t\tf2 = fn\r\n\t\tif fn % 2 == 0:\r\n\t\t\tsum += fn\r\n\r\n\treturn sum\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The problem: By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. My solution (in python): # Author: Will Clausen # # Date: Jan 6, 2013 # # This program will solve problem 2 in Project # Euler. # This function generates the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[9,21,19],"class_list":["post-87","post","type-post","status-publish","format-standard","hentry","category-project-euler-solutions","tag-january2013","tag-project-euler-problem-2","tag-project-euler-solution"],"_links":{"self":[{"href":"http:\/\/willclausen.com\/index.php?rest_route=\/wp\/v2\/posts\/87","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/willclausen.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/willclausen.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/willclausen.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/willclausen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=87"}],"version-history":[{"count":2,"href":"http:\/\/willclausen.com\/index.php?rest_route=\/wp\/v2\/posts\/87\/revisions"}],"predecessor-version":[{"id":89,"href":"http:\/\/willclausen.com\/index.php?rest_route=\/wp\/v2\/posts\/87\/revisions\/89"}],"wp:attachment":[{"href":"http:\/\/willclausen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=87"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/willclausen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=87"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/willclausen.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=87"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}