{"id":37211,"date":"2016-08-29T10:45:46","date_gmt":"2016-08-29T15:45:46","guid":{"rendered":"http:\/\/luispalominotblog.wordpress.com\/?p=468"},"modified":"2016-08-29T10:45:46","modified_gmt":"2016-08-29T15:45:46","slug":"recursion","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/recursion\/","title":{"rendered":"Recursion"},"content":{"rendered":"<p class=\"syndicated-attribution\"><em> --Originally published at <a href=\"https:\/\/luispalominotblog.wordpress.com\/2016\/08\/29\/recursion\/\"><a href=\"https:\/\/luispalominotblog.wordpress.com\">Programming<\/a><\/a><\/em><br \/><\/p>\n<h2>Definition<\/h2>\n<p>It&#8217;s time to start taking on more advanced topics. Recursion is a way to code a problem, in which a function calls itself several times withing its body. In mathematical terms a recursive function is a function that is defined in terms of itself. If a function fulfills the definition of recursion, it is then called a recursive function.<\/p>\n<h2>Terminate a recursive function<\/h2>\n<p>A recursive function needs to be terminated in a program. A recursive function is terminated when the solution of the problem is reduced and\u00a0reaches a base case. A base case is defined as the case when the problem doesn&#8217;t require further recursion in order to be solved.<\/p>\n<h2>Example<\/h2>\n<p>The factorial of a number would be a recursive problem. A simple way to make a program to get the factorial of a number n is on the left, and on the right we can find the same problem using recursion.<\/p>\n<p><img class=\"  wp-image-483 alignleft\" src=\"https:\/\/luispalominotblog.files.wordpress.com\/2016\/08\/210.png?w=336&#038;h=152\" alt=\"2.png\" width=\"336\" height=\"152\" \/><img class=\" size-full wp-image-481 alignright\" src=\"https:\/\/luispalominotblog.files.wordpress.com\/2016\/08\/111.png?w=775\" alt=\"1.png\"   \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Let&#8217;s track how the recursive function works by adding print functions to the previous function definition.<\/p>\n<p><img class=\" size-full wp-image-491 aligncenter\" src=\"https:\/\/luispalominotblog.files.wordpress.com\/2016\/08\/39.png?w=775\" alt=\"3.png\"   \/><\/p>\n<p><img class=\" size-full wp-image-493 aligncenter\" src=\"https:\/\/luispalominotblog.files.wordpress.com\/2016\/08\/49.png?w=775\" alt=\"4.png\"   \/><\/p>\n<p>If you want to learn deeper\u00a0about this topic I recommend you to read the following article that explains how to use recursion.\u00a0http:\/\/openbookproject.net\/thinkcs\/python\/english3e\/recursion.html<\/p>\n<p>&nbsp;<\/p><br \/>  <a rel=\"nofollow\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/luispalominotblog.wordpress.com\/468\/\"><img alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/comments\/luispalominotblog.wordpress.com\/468\/\" \/><\/a> <img alt=\"\" border=\"0\" src=\"https:\/\/pixel.wp.com\/b.gif?host=luispalominotblog.wordpress.com&#038;blog=115253528&%23038;post=468&%23038;subd=luispalominotblog&%23038;ref=&%23038;feed=1\" width=\"1\" height=\"1\" \/>","protected":false},"excerpt":{"rendered":"<p>&#8211;Originally published at Programming Definition It&#8217;s time to start taking on more advanced topics. Recursion is a way to code a problem, in which a function calls itself several times withing its body. In mathematical terms a recursive function is a function that is defined in terms of itself. If a function fulfills the definition &hellip; <a href=\"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/recursion\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Recursion<\/span><\/a><\/p>\n","protected":false},"author":14,"featured_media":483,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[146,24],"class_list":["post-37211","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogs","category-syndicated","tag-tc101-python-recursion-infinity","tag-python"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/37211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/comments?post=37211"}],"version-history":[{"count":2,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/37211\/revisions"}],"predecessor-version":[{"id":38372,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/37211\/revisions\/38372"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/media?parent=37211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/categories?post=37211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/tags?post=37211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}