about | help | code help+videos | done | prefs |
test2023_11_16_SLHL_sumDigits
Write a method that returns the sum of all the digits in 'num' when written in the base 'base'. As preconditions you may assume that 'base' will be between 2 and 10 inclusive and that 'num' is non-negative. For example, if 'num' is 22 and 'base' is 5 you would return 6 since 22 is written as "42" in base 5 (a 4 in the 5's place and a 2 in the 1's place) and the sum of 4 plus 2 is 6. Look at the test data for other examples. test2023_11_16_SLHL_sumDigits(21423, 7) → 15 test2023_11_16_SLHL_sumDigits(21423, 8) → 24 test2023_11_16_SLHL_sumDigits(124, 4) → 7 ...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: 260
Copyright Nick Parlante 2017 - privacy