Count the multiples
Inputs
values is a list of 0 to 14 whole numbers, each from 0 to 60. d is a whole number from 1 to 9.
Your tasks
- Create a number
countthat starts at 0. - Use a loop over
values. Add 1 tocountfor each number that divides evenly byd. - Complete
countDivisibleso it returnscount. Return it, do not print it.
Example
With values = [6, 9, 10, 12, 0] and d = 3, countDivisible returns 4.
Rules
- 0 divides evenly by any
d.
Test data
TEST DATA 1: values is [6, 9, 10, 12, 0], d is 3
TEST DATA 2: values is [], d is 5
Practice focus
Put an if inside the loop to keep, skip or change items. Filtering, mapping and comparing neighbours show up in nearly every array question.