Find Numbers from N to 1
Find Numbers from N to 1
Tags: Loops Basics
Credit: CodingChallenge
Difficulty: Beginner
Type: Text
Category: Practice
Time Allowed: 5 s
Description:
Write a function that takes a positive integer N and returns a list of numbers from N down to 1. This problem is designed to help you practice looping backwards using a for loop
. The function should accept one parameter and return the list of numbers.
Constraints:
- The input will be a positive
integer
greater than zero. - The function should
return
alist
of integers from N down to 1 inclusive.
Example:
- Input:
5
- Output:
[5, 4, 3, 2, 1]
Test Case | Input | Expected Output |
---|---|---|
1 | 1 | [1] |
2 | 5 | [5, 4, 3, 2, 1] |
3 | 10 | [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] |
4 | 3 | [3, 2, 1] |
Leave a Comment
Please login to leave a comment.