Write a function to find all numbers in an array that are divisible by a given number.
HardProblem Statement
Write a function to find all numbers in an array that are divisible by a given number.
Sample Input
Hardcoded array [10, 15, 20, 25, 30] and divisor 5.
Sample Output
Numbers divisible by 5: [10, 15, 20, 25, 30]
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
fun findDivisibleNumbers(nums: Array<Int>, divisor: Int): List<Int> {
// Add your code here to find divisible numbers
}
fun main() {
val nums = arrayOf(10, 15, 20, 25, 30)
val divisor = 5
println("Numbers divisible by $divisor: ${findDivisibleNumbers(nums, divisor)}")
}
Input
Hardcoded array [10, 15, 20, 25, 30] and divisor 5.
Expected Output
Numbers divisible by 5: [10, 15, 20, 25, 30]