

# Hi there, I'm Alpha, a 12-year-old student at Evergreen Middle School who loves programming! I am in the Quest program which means i am accelerated.
# Today, I'm going to teach you about the magical world of recursion in programming.
# Don't worry; I'll explain it in a way that's easy to understand, and I'll use different programming languages like Python, C++, and C#.About me:
# I may be young, but I'm passionate about coding. I believe that anyone can learn to program, no matter their age.
# Join me on this exciting journey to explore the power of recursion!
// In C++, recursion looks like this:
#include <iostream>
void countdown(int n) {
if (n == 0) {
std::cout << "Blastoff!" << std::endl;
} else {
std::cout << n << std::endl;
countdown(n - 1); // Calling itself
}
}
int main() {
countdown(5);
return 0;
}// In C#, you can write a recursive function like this:
using System;
class Program {
static void Countdown(int n) {
if (n == 0) {
Console.WriteLine("Blastoff!");
} else {
Console.WriteLine(n);
Countdown(n - 1); // Calling itself
}
}
static void Main(string[] args) {
Countdown(5);
}
}# And in Python, recursion is simply elegant:
def countdown(n):
if n == 0:
print("Blastoff!")
else:
print(n)
countdown(n - 1) # Calling itself
countdown(5)The magic of Recursion:
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
result = factorial(5)
print("Factorial of 5 is:", result)
// Recursive Fibonacci in C++:
#include <iostream>
int fibonacci(int n) {
if (n <= 1) {
return n;
} else {
return fibonacci(n - 1) + fibonacci(n - 2);
}
}
int main() {
int result = fibonacci(7);
std::cout << "Fibonacci at position 7 is: " << result << std::endl;
return 0;
}// Recursive Fibonacci in C#:
using System;
class Program {
static int Fibonacci(int n) {
if (n <= 1) {
return n;
} else {
return Fibonacci(n - 1) + Fibonacci(n - 2);
}
}
static void Main(string[] args) {
int result = Fibonacci(7);
Console.WriteLine("Fibonacci at position 7 is: " + result);
}
}