Countdown
Inputs
n is a whole number from 0 to 20.
Your tasks
- Create an empty list
numbers. - Use a loop that counts downward. Add
n, thenn - 1, and so on, down to and including 1. - Complete
countdownso it returnsnumbers. Return it, do not print it.
Example
With n = 5, countdown returns [5, 4, 3, 2, 1].
Rules
- If
nis 0, return an empty list.
Test data
TEST DATA 1: n is 5
TEST DATA 2: n is 0
Practice focus
Loops that count, add up and multiply. Every algorithm starts here: a counter, a total and a stopping point.