{"id":37976,"date":"2016-10-10T12:08:46","date_gmt":"2016-10-10T17:08:46","guid":{"rendered":"https:\/\/kenscourses.com\/tc101fall2016\/?guid=13ed7989d5b99f79e53b616c1b481757"},"modified":"2016-10-10T12:08:46","modified_gmt":"2016-10-10T17:08:46","slug":"oops-i-did-it-again","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/oops-i-did-it-again\/","title":{"rendered":"OOPS! I DID IT AGAIN"},"content":{"rendered":"<p class=\"syndicated-attribution\"><em> --Originally published at <a href=\"http:\/\/emnl.me\/oops-i-did-it-again\/\"><a href=\"http:\/\/emnl.me\/\">Coding The Future<\/a><\/a><\/em><br \/><\/p>\n<p><iframe src=\"http:\/\/giphy.com\/embed\/WaCqurI4KXOxO\" width=\"480\" height=\"291\" frameborder=\"0\" class=\"giphy-embed\" allowfullscreen><\/iframe><\/p><p><a href=\"https:\/\/giphy.com\/gifs\/britney-spears-music-video-oops-i-did-it-again-WaCqurI4KXOxO\">via GIPHY<\/a><\/p><p><\/p>\n\n<p>Hello my fellow programmers! I'm back again with a new and interesting topic for today. And I know, I said I would stop with the song references, but I just can't!<\/p>\n\n<p>Today, I'm quoting Britney and her masterpiece <a href=\"https:\/\/play.spotify.com\/album\/5PmgtkodFl2Om3hMXONDll?play=true&amp;utm_source=open.spotify.com&amp;utm_medium=open\"><em>Oops! I did it again<\/em><\/a> to get us started on the topic of <strong>recursion<\/strong>. Recursion is the repetition of an algorithm for as many times as necessary to generate a conclusion. <\/p>\n\n<h4 id=\"whatisrecursion\">What is recursion?<\/h4>\n\n<p>Recursion is funny because it's kind of related to infinity. Is not the same as loop, because the function \"calls itself more than one time within its own body\"<sup id=\"fnref:1\"><a href=\"http:\/\/emnl.me\/oops-i-did-it-again\/#fn:1\" rel=\"footnote\">1<\/a><\/sup>, becoming something like a function inside a function, inside a function, inside a function, and so on. It can also be interpreted as solving a big problem in smaller and smaller portions, and solving the first and smallest, followed by the second, until reaching the final big problem. However, a recursive function must end at some point to successfully obtain an answer.<\/p>\n\n<p>Let's dive deeper into the topic. To do that, we will explore a popular example.<\/p>\n\n<h4 id=\"examplesofrecursion\">Examples of recursion<\/h4>\n\n<p>The Fibonacci numbers are the numbers of the following sequence of integer values: <\/p>\n\n<p>0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... <\/p>\n\n<p>The Fibonacci numbers are defined by: <br>\nF<sub>n<\/sub> = F<sub>n-1<\/sub> + F<sub>n-2<\/sub> with F<sub>0<\/sub> = 0 and F<sub>1<\/sub> = 1.<\/p>\n\n<p>If we wanted to write a function that returns a determined index of the of Fibonacci series we would use something like this:<\/p>\n\n<p><code>def fibo(n):\n    if n == 0:\n        return 0\n    elif n == 1:\n        return 1\n    else:\n        return fibo(n-1) + fibo(n-2)<\/code><\/p>\n\n<p>As you may notice, the else statement, which exits within <em>fibo<\/em> calls itself again, until the the if or the elif are reached. If <!--more--> printed step by step, we would see how the function works backwards until it reaches 1, and then it works its way up. This is a clear example of recursion. <\/p>\n\n<p>A more detailed explanation is available at <a href=\"http:\/\/www.python-course.eu\/recursive_functions.php\">PythonCourse<\/a>.<\/p>\n\n<p>In conclusion, recursion is used when one must go back to the \"first known index\" and work all the way up to return the index the user expects to see.<\/p>\n\n<p>That's all for today! See y'all next time. ? <br>\n<a href=\"http:\/\/twitter.com\/emamex98\">@emamex98<\/a><\/p>\n\n<div id=\"disqus_thread\"><\/div>  \n\n<script type=\"text\/javascript\">  \n    var disqus_shortname = 'emnl-me';\n    var disqus_identifier = 'recursion';\n\n    (function() {\n        var dsq = document.createElement('script'); dsq.type = 'text\/javascript'; dsq.async = true;\n        dsq.src = '\/\/' + disqus_shortname + '.disqus.com\/embed.js';\n        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);\n    })();\n<\/script>  \n\n<noscript>Please enable JavaScript to view the <a href=\"http:\/\/disqus.com\/?ref_noscript\">comments powered by Disqus.<\/a><\/noscript>  \n\n<p><a href=\"http:\/\/disqus.com\/\" class=\"dsq-brlink\">comments powered by <span class=\"logo-disqus\">Disqus<\/span><\/a> <\/p>","protected":false},"excerpt":{"rendered":"<p>&#8211;Originally published at Coding The Future via GIPHY Hello my fellow programmers! I&#8217;m back again with a new and interesting topic for today. And I know, I said I would stop with the song references, but I just can&#8217;t! Today, I&#8217;m quoting Britney and her masterpiece Oops! I did it again to get us started &hellip; <a href=\"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/oops-i-did-it-again\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">OOPS! I DID IT AGAIN<\/span><\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[126,286],"class_list":["post-37976","post","type-post","status-publish","format-standard","hentry","category-blogs","category-syndicated","tag-functions","tag-recursion"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/37976","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\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/comments?post=37976"}],"version-history":[{"count":1,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/37976\/revisions"}],"predecessor-version":[{"id":37977,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/37976\/revisions\/37977"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/media?parent=37976"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/categories?post=37976"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/tags?post=37976"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}