<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ai-yugi</title>
    <description>The latest articles on DEV Community by ai-yugi (@aiyugi).</description>
    <link>https://dev.to/aiyugi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F981429%2F056098fc-9205-44e6-a795-d257da6d2893.png</url>
      <title>DEV Community: ai-yugi</title>
      <link>https://dev.to/aiyugi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aiyugi"/>
    <language>en</language>
    <item>
      <title>What is Recursion in Programming?</title>
      <dc:creator>ai-yugi</dc:creator>
      <pubDate>Thu, 08 Feb 2024 12:03:38 +0000</pubDate>
      <link>https://dev.to/aiyugi/what-is-recursion-in-programming-jc</link>
      <guid>https://dev.to/aiyugi/what-is-recursion-in-programming-jc</guid>
      <description>&lt;p&gt;&lt;strong&gt;Recursion&lt;/strong&gt; is a programming concept where a function calls itself either directly or indirectly to solve a smaller instance of the same problem. This is done by breaking down a larger problem until a base case that can easily be solved is reached.&lt;/p&gt;

&lt;p&gt;Okay, that might have been a mouthful; in other words, a recursive function is a function that performs a task in part and delegates the remaining task to a new invocation of itself.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example;&lt;/em&gt;&lt;br&gt;
For instance you want to write a function that calculates the factorial of a number where the factorial of a non-negative integer n is the product of all positive integers less than or equal to n.&lt;/p&gt;

&lt;p&gt;Let’s start by seeing how this problem can be solved using a non recursive function first;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fibmu6khnfnkv1nhymy0d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fibmu6khnfnkv1nhymy0d.png" alt="Image description" width="800" height="543"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now here’s the solution using a recursive function;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabo3xemlfkdbl8vfn6h4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabo3xemlfkdbl8vfn6h4.png" alt="Image description" width="800" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>python</category>
      <category>ai</category>
      <category>recursion</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
