<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: 7.10 &#8212; Recursion</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/710-recursion/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/710-recursion/</link>
	<description></description>
	<lastBuildDate>Thu, 02 Feb 2012 21:20:10 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: abdelones</title>
		<link>http://www.learncpp.com/cpp-tutorial/710-recursion/comment-page-1/#comment-96869</link>
		<dc:creator>abdelones</dc:creator>
		<pubDate>Sun, 22 Jan 2012 03:35:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/710-recursion/#comment-96869</guid>
		<description>hi every one i hope you can help me with this i found this countdown code in C 
******************************
void countdown(int n)
{
    if (n&lt;10)
    {
        countdown()(n+1);
        printf(&quot;%d\n&quot;, n);
     }
  
}

void main()
{
    countdown()(1);
    getch();


}
*********************************
when it&#039;s done we can saw countdown printed like that
9
8
7
.
.
.
the problem is that i just can&#039;t understand how it works and why it print last numbers in the first place ?  seek_help ;)</description>
		<content:encoded><![CDATA[<p>hi every one i hope you can help me with this i found this countdown code in C<br />
******************************<br />
void countdown(int n)<br />
{<br />
    if (n&lt;10)<br />
    {<br />
        countdown()(n+1);<br />
        printf(&quot;%d\n&quot;, n);<br />
     }</p>
<p>}</p>
<p>void main()<br />
{<br />
    countdown()(1);<br />
    getch();</p>
<p>}<br />
*********************************<br />
when it&#039;s done we can saw countdown printed like that<br />
9<br />
8<br />
7<br />
.<br />
.<br />
.<br />
the problem is that i just can&#039;t understand how it works and why it print last numbers in the first place ?  seek_help ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zingmars</title>
		<link>http://www.learncpp.com/cpp-tutorial/710-recursion/comment-page-1/#comment-96117</link>
		<dc:creator>zingmars</dc:creator>
		<pubDate>Sat, 08 Oct 2011 12:58:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/710-recursion/#comment-96117</guid>
		<description>Use int (int64 or something) instead of double, and you won&#039;t loose precision.</description>
		<content:encoded><![CDATA[<p>Use int (int64 or something) instead of double, and you won&#8217;t loose precision.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mael</title>
		<link>http://www.learncpp.com/cpp-tutorial/710-recursion/comment-page-1/#comment-95317</link>
		<dc:creator>mael</dc:creator>
		<pubDate>Tue, 12 Apr 2011 00:15:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/710-recursion/#comment-95317</guid>
		<description>#include 

using std::cout;
using std::cin;
int main()
{
double nOld(0), nNew(1), nSum(0), nThfibo; 
   cout &lt;&lt; &quot;Numbers above the 30th, loose precision so \n&quot;;
   cout &lt;&lt; &quot;the 29th and the 30th numbers are 514,229 and 832,040 maybe you should go manual from there \n \n&quot;;
   cout &lt;&gt; nThfibo;
   
      int iii = 1;
        while (iii &lt; nThfibo)
              {
                   nSum = nOld + nNew;
                   nOld = nNew;
                   nNew = nSum;
                   iii++;
              }
cout &lt;&lt; nSum &lt;&lt; &quot; is the &quot; &lt;&lt; nThfibo &lt;&lt; &quot;th Fibonacci number.\n&quot;;

cin.clear();
cin.ignore(255, &#039;\n&#039;);
cin.get();
return 0;
}
Faster way to get the Fibbo you want?
but above 30th number you loose precision anyway to fix it??
Greate site :)</description>
		<content:encoded><![CDATA[<p>#include </p>
<p>using std::cout;<br />
using std::cin;<br />
int main()<br />
{<br />
double nOld(0), nNew(1), nSum(0), nThfibo;<br />
   cout &lt;&lt; &quot;Numbers above the 30th, loose precision so \n&quot;;<br />
   cout &lt;&lt; &quot;the 29th and the 30th numbers are 514,229 and 832,040 maybe you should go manual from there \n \n&quot;;<br />
   cout &lt;&gt; nThfibo;</p>
<p>      int iii = 1;<br />
        while (iii &lt; nThfibo)<br />
              {<br />
                   nSum = nOld + nNew;<br />
                   nOld = nNew;<br />
                   nNew = nSum;<br />
                   iii++;<br />
              }<br />
cout &lt;&lt; nSum &lt;&lt; &quot; is the &quot; &lt;&lt; nThfibo &lt;&lt; &quot;th Fibonacci number.\n&quot;;</p>
<p>cin.clear();<br />
cin.ignore(255, &#039;\n&#039;);<br />
cin.get();<br />
return 0;<br />
}<br />
Faster way to get the Fibbo you want?<br />
but above 30th number you loose precision anyway to fix it??<br />
Greate site :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Moogie</title>
		<link>http://www.learncpp.com/cpp-tutorial/710-recursion/comment-page-1/#comment-95193</link>
		<dc:creator>Moogie</dc:creator>
		<pubDate>Sun, 20 Feb 2011 22:55:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/710-recursion/#comment-95193</guid>
		<description>Oh god damnit. This forum software sucks balls and butchered my reply. Now it makes no sense, AND I can&#039;t even delete it or edit it!</description>
		<content:encoded><![CDATA[<p>Oh god damnit. This forum software sucks balls and butchered my reply. Now it makes no sense, AND I can&#8217;t even delete it or edit it!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Moogie</title>
		<link>http://www.learncpp.com/cpp-tutorial/710-recursion/comment-page-1/#comment-95192</link>
		<dc:creator>Moogie</dc:creator>
		<pubDate>Sun, 20 Feb 2011 22:54:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/710-recursion/#comment-95192</guid>
		<description>You supplied the initial value (10) for CountDown to use, but then didn&#039;t implement any way for it to stop at 0. Your &quot;while(nValue&quot; instead.

Then again, I don&#039;t see why this works at all. Right from the start, &quot;10 &lt; 0&quot; is false, so it shouldn&#039;t print anything at all...</description>
		<content:encoded><![CDATA[<p>You supplied the initial value (10) for CountDown to use, but then didn&#8217;t implement any way for it to stop at 0. Your &#8220;while(nValue&#8221; instead.</p>
<p>Then again, I don&#8217;t see why this works at all. Right from the start, &#8220;10 &lt; 0&quot; is false, so it shouldn&#039;t print anything at all&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nelson Jenkins</title>
		<link>http://www.learncpp.com/cpp-tutorial/710-recursion/comment-page-1/#comment-95151</link>
		<dc:creator>Nelson Jenkins</dc:creator>
		<pubDate>Fri, 04 Feb 2011 07:15:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/710-recursion/#comment-95151</guid>
		<description>Probably related to the compiler and your RAM, or maybe even the byte size of your operating system (I hit -130,146 before crashing, just like clementl below me, and I&#039;ve got 12 GB of RAM using Dev-C++ on Windows 7 64-bit). Perhaps the compiler Quinn used had some kind of fancy dynamic/large stack, unless he has a few TB of RAM.

Fun to test, though. Someone should make a program using this principle that pops up error messages instead of cout&#039;s to simulate the Windows experience for Mac/Linux users!</description>
		<content:encoded><![CDATA[<p>Probably related to the compiler and your RAM, or maybe even the byte size of your operating system (I hit -130,146 before crashing, just like clementl below me, and I&#8217;ve got 12 GB of RAM using Dev-C++ on Windows 7 64-bit). Perhaps the compiler Quinn used had some kind of fancy dynamic/large stack, unless he has a few TB of RAM.</p>
<p>Fun to test, though. Someone should make a program using this principle that pops up error messages instead of cout&#8217;s to simulate the Windows experience for Mac/Linux users!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: clementl</title>
		<link>http://www.learncpp.com/cpp-tutorial/710-recursion/comment-page-1/#comment-95071</link>
		<dc:creator>clementl</dc:creator>
		<pubDate>Thu, 23 Dec 2010 14:01:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/710-recursion/#comment-95071</guid>
		<description>My pc stopped at -130146. Facinating!</description>
		<content:encoded><![CDATA[<p>My pc stopped at -130146. Facinating!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dr. HaXX</title>
		<link>http://www.learncpp.com/cpp-tutorial/710-recursion/comment-page-1/#comment-94930</link>
		<dc:creator>Dr. HaXX</dc:creator>
		<pubDate>Tue, 16 Nov 2010 12:26:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/710-recursion/#comment-94930</guid>
		<description>&quot;On the authors machine, this program counted down to -11732 before terminating!&quot;
Then you must have quite some stack memory, my computer stopped counting at -4607 xD

&quot;Hahaha… apparently Linux doesn’t believe in stack overflows. 
I ran your stack overflowing program and it just kept going all the way past -4,000,000, when I stopped it.&quot;

Lmao, apparently you have infinite stack memory on your pc :P</description>
		<content:encoded><![CDATA[<p>&#8220;On the authors machine, this program counted down to -11732 before terminating!&#8221;<br />
Then you must have quite some stack memory, my computer stopped counting at -4607 xD</p>
<p>&#8220;Hahaha… apparently Linux doesn’t believe in stack overflows.<br />
I ran your stack overflowing program and it just kept going all the way past -4,000,000, when I stopped it.&#8221;</p>
<p>Lmao, apparently you have infinite stack memory on your pc :P</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lunchmeat</title>
		<link>http://www.learncpp.com/cpp-tutorial/710-recursion/comment-page-1/#comment-94266</link>
		<dc:creator>lunchmeat</dc:creator>
		<pubDate>Wed, 20 Oct 2010 00:43:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/710-recursion/#comment-94266</guid>
		<description>Hey there.

I&#039;m just another guy who&#039;s been reading through your tutorials (not always in a linear fashion) and I liked this one - especially coming from the previous article dealing with stack memory.

I noticed something - when I write recursive statements, I don&#039;t use a return statement until I break the recursion. I noticed that you use return statements as part of your recursion. For example:

&lt;pre&gt;// return the sum of 1 to nValue
int SumTo(int nValue)
{
    if (nValue &lt;=1)
        return nValue;
    else
        return SumTo(nValue - 1) + nValue;
}&lt;/pre&gt;

When I&#039;ve written code like this, I wouldn&#039;t have thought to put the function call after a return statement in the else block. (In practice, it yields the same results.) You may have stated this, but I may have missed it - does using a return statement in front of the recursive function prevent the stack from filling up? Based on how you stated stacks worked in the previous tutorial, this seems to make sense...by issuing a return statement, the function variables and whatnot are removed from the stack each time it recurses so it doesn&#039;t build up. Am I right or am I missing something? It seems to make sense, but something isn&#039;t quite right....

As a side note, I made my own fibonacci sequence before reading this article (as practice for command-line arguments) but I used a recursive sequence that added the last and second-to-last numbers to get the next number. 1+1=2, 2+1=3, 3+2=5, 5+3=8, and so on. Seems like this method takes less overhead?

Thank you for your tutorials!</description>
		<content:encoded><![CDATA[<p>Hey there.</p>
<p>I&#8217;m just another guy who&#8217;s been reading through your tutorials (not always in a linear fashion) and I liked this one &#8211; especially coming from the previous article dealing with stack memory.</p>
<p>I noticed something &#8211; when I write recursive statements, I don&#8217;t use a return statement until I break the recursion. I noticed that you use return statements as part of your recursion. For example:</p>
<pre>// return the sum of 1 to nValue
int SumTo(int nValue)
{
    if (nValue &lt;=1)
        return nValue;
    else
        return SumTo(nValue - 1) + nValue;
}</pre>
<p>When I&#8217;ve written code like this, I wouldn&#8217;t have thought to put the function call after a return statement in the else block. (In practice, it yields the same results.) You may have stated this, but I may have missed it &#8211; does using a return statement in front of the recursive function prevent the stack from filling up? Based on how you stated stacks worked in the previous tutorial, this seems to make sense&#8230;by issuing a return statement, the function variables and whatnot are removed from the stack each time it recurses so it doesn&#8217;t build up. Am I right or am I missing something? It seems to make sense, but something isn&#8217;t quite right&#8230;.</p>
<p>As a side note, I made my own fibonacci sequence before reading this article (as practice for command-line arguments) but I used a recursive sequence that added the last and second-to-last numbers to get the next number. 1+1=2, 2+1=3, 3+2=5, 5+3=8, and so on. Seems like this method takes less overhead?</p>
<p>Thank you for your tutorials!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bob</title>
		<link>http://www.learncpp.com/cpp-tutorial/710-recursion/comment-page-1/#comment-91345</link>
		<dc:creator>Bob</dc:creator>
		<pubDate>Fri, 03 Sep 2010 20:42:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/710-recursion/#comment-91345</guid>
		<description>Is there actually a use of fibonacci numbers in C++? Apart from in a maths program!</description>
		<content:encoded><![CDATA[<p>Is there actually a use of fibonacci numbers in C++? Apart from in a maths program!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

