Recursive Countdown Sequence

Recursion Algorithm Holiday

Problem Description

On this festive Christmas day, we invite you to write a recursive function that creates a "countdown sequence". Given a positive integer n, your function should return a list (or array) that starts at n, counts down to 1, and then counts back up to n (excluding the repetition of 1 in the upward count).

For example:

  • If n = 3, then the sequence would be: [3, 2, 1, 2, 3]
  • If n = 5, then the sequence would be: [5, 4, 3, 2, 1, 2, 3, 4, 5]

Requirements

  • Use recursion to build the sequence.
  • Do not use loops (for, while) to build the sequence, though you may use them for auxiliary tasks (like output printing) if needed.
  • Your solution should be solvable in under 45 minutes.

Starter Code

Below is some language-agnostic starter code for various languages to help you get started.