{"id":114,"date":"2014-02-25T14:45:57","date_gmt":"2014-02-25T03:45:57","guid":{"rendered":"http:\/\/www.lazydungeon.com\/blog\/?p=114"},"modified":"2014-02-25T14:45:57","modified_gmt":"2014-02-25T03:45:57","slug":"continued-fraction","status":"publish","type":"post","link":"https:\/\/www.lazydungeon.com\/blog\/continued-fraction\/","title":{"rendered":"Continued Fraction"},"content":{"rendered":"<p>After a 6 month break, I&#8217;m back at project Euler again.<\/p>\n<p>One of the new problems: continued fraction calculation, I find it really odd that there&#8217;s no a lot of good source on a step by step algorithm to calculate it. So I&#8217;m just going to write it here, in python.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n#calculate the sqrt of a number as a series of continued fraction co-efficient\r\nnum = 22\r\nsqrt = Decimal(num).sqrt()\r\nif math.ceil(sqrt) != math.floor(sqrt) : #wish I know a better way to check this\r\n    while count &lt; 100 : # wirte out the first 100\r\n        count = count + 1\r\n        sqrt = Decimal(1) \/ (sqrt - Decimal(math.floor(sqrt)));\r\n        print (sqrt)\r\n<\/pre>\n<p>Also learning python, which is pretty fun.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After a 6 month break, I&#8217;m back at project Euler again. One of the new problems: continued fraction calculation, I find it really odd that there&#8217;s no a lot of good source on a step by step algorithm to calculate it. So I&#8217;m just going to write it here, in python. #calculate the sqrt of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-114","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.lazydungeon.com\/blog\/wp-json\/wp\/v2\/posts\/114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lazydungeon.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lazydungeon.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lazydungeon.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lazydungeon.com\/blog\/wp-json\/wp\/v2\/comments?post=114"}],"version-history":[{"count":4,"href":"https:\/\/www.lazydungeon.com\/blog\/wp-json\/wp\/v2\/posts\/114\/revisions"}],"predecessor-version":[{"id":119,"href":"https:\/\/www.lazydungeon.com\/blog\/wp-json\/wp\/v2\/posts\/114\/revisions\/119"}],"wp:attachment":[{"href":"https:\/\/www.lazydungeon.com\/blog\/wp-json\/wp\/v2\/media?parent=114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lazydungeon.com\/blog\/wp-json\/wp\/v2\/categories?post=114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lazydungeon.com\/blog\/wp-json\/wp\/v2\/tags?post=114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}