Buckys C++ Programming Tutorials - 31 - Recursion
Top Comments
All Comments (127)
-
I learned how to do this in my brain before I knew what it was... sweet brag.
-
look at the call stack debug window and step through the code. that will help you see how the compiler interprets this code.
-
i try and explain this to you:
factorial(5) returns 5*factorial(4)
factorial(4) returns 4*factorial(3)
factorial(3) returns 3*factorial(2)
factorial(2) returns 2*factorial(1)
factorial(1) returns 1
and then it goes backwards to top like this 1*2*3*4*5 = 120 :) hope you understood this guys .
p.s. thumbs up for Bucky :D
-
inception++?
-
INCEPTION: C++ Edition.
-
@ryangr0 ye but not half as sexy
-
@theubunny if you look at the first video of this tutorial series, you'll see this is Code::Blocks
-
What is this program name? Is it Dev C++?
-
factorialFinder(0);
-
Lets write it in other way:
int fact(int x){ return (x<=1?1:x*fact(x-1));
}
For an explaination of recurrsion see the bottom of this comment...
For an explaination of recurrison see the top of this comment...
mgstanger 7 months ago 50
Wouldn't this be way easier just using a for loop?
ryangr0 3 months ago 4