kotlin-coding-challenges

Print numbers with steps

Instructions

Given positive integer n and integer step implement a function which returns a list representing all numbers from n to 1 taking step into consideration. If n value is zero then empty list should be returned.

Challenge Solution

Examples

printNumber(0, 1) // []

printNumber(6, 1) // [6, 5, 4, 3, 2, 1]

printNumber(6, 2) // [6, 4, 2]