Good example! This is a very approachable one, because the idea of "adding two numbers together" is fairly universal, and a simple example makes it easier to understand a complex concept.
I have a few small pieces of feedback on this article, which you're welcome to consider, discuss, and/or disagree with :)
The title of your post has an implied "Always" at the beginning. That is, some people will interpret the title as "Always Replace Loops Using Recursion", which is often not the case (in some scenarios, loops are a better tool to use than recursion). I think a more accurate title would be "How To Replace Loops Using Recursion", which matches the content better.
In your description of the task, you say "Add the first n elements of an array to create the product of those elements." I think you meant to use the term "result" instead of "product" - "product" usually means "the result of multiplication", i.e. the product of 2 and 3 is 2 * 3 = 6.
In your first sentence, you say "Recursion is the concept that a function can be expressed in terms of itself." In your example, I would recommend directly pointing out the code that makes sum a recursive function (specifically, the fifth line, where it calls itself). This explicitly shows your readers how the concept appears in code, which can help them reinforce the core idea.
Tech enthusiast studying ICT and graduating soon enough๐จ๐ฟโ๐. Software Engineer in the making, experimenting my way through life. I'm here to connect, learn from y'all and share my knowledge.๐๐ฟ
Good example! This is a very approachable one, because the idea of "adding two numbers together" is fairly universal, and a simple example makes it easier to understand a complex concept.
I have a few small pieces of feedback on this article, which you're welcome to consider, discuss, and/or disagree with :)
suma recursive function (specifically, the fifth line, where it calls itself). This explicitly shows your readers how the concept appears in code, which can help them reinforce the core idea.Thanks for the article, feel free to respond!
Great feedback!