hello i just made a program that uses recursive functions. but i am not sure if this is really recursion or just something else. (i'm just trying to find out about it myself instead of reading about it). and in my code i am using 2 global variables but they are annoying me. so could anyone tell me how to do it without them ? if that is even possible. i am sorry for looking so newbie :D.
You've got a base case and a repeatable procedure for finding the answer. It's recursion.
@Vlad: Yes...?
To avoid the use of globals you can use the return value of the previous call, and decrement the x before passing it so you can just compare it to zero:
You've got a base case and a repeatable procedure for finding the answer. It's recursion.
Since i'm new to the concept of recursion i don't know what you mean with the base case and a repeatable procedure.
maybe you could show me where in the code they are?
thanks in advance.