Lecture 9: A simple recursive function - Richard Buckland UNSW
Top Comments
All Comments (30)
-
Waste of time.
-
@nateaus In other words, they shouldn't have called the movie inception, they should have called it recursion.
-
@Izooify he is not personally seeing the comments now is he
-
I'll follow every lecture he says.
-
Hello Sir; I've beening following ur Lectures on YouTube But I've Gotten Stuck Here on this lecture 9 my compiler is returning an error message : 'SUM' is asigned a value which is never used ? Please help me here my compiler is not recognizing 'n'
-
As a tack on to my prior statement (I ran out of room). This appears very similar to recursion because in fact it is. If it helps try imagine little Russian dolls in succession and if that helps here is a quote from "Back to the Future":
"you're not thinking fourth dimensionally"
Love Victor Cross
-
Dear nateaus.
This appears very similar to recursion as the function is calling it's self. All though it is true that the function is passing n-1 into its self on the in function call in the new call that is treated the same way as n would be and that is where the increment is happening. The part that allows it not to run infinitely is the if statement at the top of the function searching for when n is o at which point it returns 0 and then terminates the original call and all subsequent calls.
-
Interesting. I thought recursion when a method calls itself regardless of any counting mechanism.
-
@intindse Microsoft doesn't too.



Actually this is not recursion. Your example is just repeatedly calling a function.
Recursion is when a function calls itself. But the self-call needs to modify the n value. Eg n-1 or n+1, so each subsequent call modifies the n value and moves closer to the final output. Otherwise there would be an endless loop.
If you look at 29:43 you will see the function calls itself with but with (n -1).
nateaus 2 years ago 7
His shirt, "Microsoft security". Ha.
SauronsEye 2 years ago 7