Skip to content

Commit

Permalink
Update Recursion.md
Browse files Browse the repository at this point in the history
  • Loading branch information
memcmahon authored Jan 9, 2024
1 parent 6939931 commit 893f6a4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions module6/lessons/Week5/Recursion.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class Program

static void RecursiveCountdown(int num)
{
if (num == )
if (num == 0)
{
Console.WriteLine(num);
}
Expand All @@ -59,9 +59,15 @@ public class Program
}
```

<section class='instructor-notes' markdown='1'>

Make sure to identify the following characteristics of the method above - talk specifically about how the recursive instructions move us closer to the base case.

</section
This is a very simple example of recursion, but it does give us a chance to identify the key features of a recursive function. Every recursive function must have these two pieces:
1. A **base case**: a terminating scenario that _does not use recursion_ to produce an answer
2. A **recursive case**: a set of instructions, movign closer towards the base case, that ends in a call to the same function
2. A **recursive case**: a set of instructions, moving closer towards the base case, that ends in a call to the same function
### Use Cases
Expand Down Expand Up @@ -175,4 +181,4 @@ n | collatz(n) |Steps
5 | 5 | 5 -> 16 -> 8 -> 4 -> 2 -> 1
6 | 8 | 6 -> 3 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1



0 comments on commit 893f6a4

Please sign in to comment.