<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://coderwiki.org/index.php?action=history&amp;feed=atom&amp;title=Recursion</id>
	<title>Recursion - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://coderwiki.org/index.php?action=history&amp;feed=atom&amp;title=Recursion"/>
	<link rel="alternate" type="text/html" href="http://coderwiki.org/index.php?title=Recursion&amp;action=history"/>
	<updated>2026-05-19T06:26:03Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>http://coderwiki.org/index.php?title=Recursion&amp;diff=74&amp;oldid=prev</id>
		<title>Dylan: new: info, examples (pseudocode, c recursion, c iteration)</title>
		<link rel="alternate" type="text/html" href="http://coderwiki.org/index.php?title=Recursion&amp;diff=74&amp;oldid=prev"/>
		<updated>2025-08-12T11:53:56Z</updated>

		<summary type="html">&lt;p&gt;new: info, examples (pseudocode, c recursion, c iteration)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Recursion&amp;#039;&amp;#039;&amp;#039; is the process of &amp;#039;&amp;#039;&amp;#039;repeating code&amp;#039;&amp;#039;&amp;#039; by calling a [[subroutine]] from within that same [[subroutine]].&lt;br /&gt;
&lt;br /&gt;
== Pseudocode example ==&lt;br /&gt;
 function factorial(n: int) -&amp;gt; int&lt;br /&gt;
     if n &amp;lt;= 1 then&lt;br /&gt;
         return n&lt;br /&gt;
     endif&lt;br /&gt;
     return n * factorial(n - 1)&lt;br /&gt;
 endfunction&lt;br /&gt;
&lt;br /&gt;
== [[C]] example ==&lt;br /&gt;
The same code in the &amp;#039;&amp;#039;&amp;#039;C&amp;#039;&amp;#039;&amp;#039; [[programming language]] would look like this:&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
int factorial(int n) {&lt;br /&gt;
    if (n == 1) {               &lt;br /&gt;
        return n;&lt;br /&gt;
    }&lt;br /&gt;
    return n * factorial(n - 1);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The same [[C]] code with [[iteration]] ==&lt;br /&gt;
The alternative to using &amp;#039;&amp;#039;&amp;#039;recursion&amp;#039;&amp;#039;&amp;#039; would be to use &amp;#039;&amp;#039;&amp;#039;[[iteration]]&amp;#039;&amp;#039;&amp;#039;. This isn&amp;#039;t always the best option, so sometimes iteration is a better choice:&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
int factorial(int n) {&lt;br /&gt;
    int result = n;&lt;br /&gt;
    for (int i = n-1; i &amp;gt; 1; i--) {&lt;br /&gt;
	result *= i;&lt;br /&gt;
    }&lt;br /&gt;
    return result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Dylan</name></author>
	</entry>
</feed>