about | help | code help+videos | done | prefs |
Write a method that returns the sum of selected numbers from the 'nums' array. Only use numbers that are a multiple of 'multOf'. For example, if 'multOf' was 3, you would only use the numbers in 'nums' that are multiples of 3 in finding the sum. So, if 'nums' is {7,9,15,20,33} and 'multOf' is 3, you would return 57 because 9+15+33=57 (since 9, 15, and 33 were the only multiples of 3 in the array, they were the only numbers that counted towards the sum). Note: If 'multOf' is 1, you will return the sum of ALL the integers in 'nums' because all numbers in the array must be multiples of 1. Preconditions: 'nums' will only contain positive integers, but can be any length, including a length of zero. The parameter 'multOf' will be a positive integer. quiz2023_04_25_P1SLHL_sumMults([12, 35, 54, 124, 567, 24, 142, 6, 35, 75, 21, 856, 35, 85, 124, 3456], 6) → 3552 quiz2023_04_25_P1SLHL_sumMults([], 1) → 0 quiz2023_04_25_P1SLHL_sumMults([], 5) → 0 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 230
Copyright Nick Parlante 2017 - privacy