about | help | code help+videos | done | prefs |
Write a method that recursively returns the sum of the digit representation of the parameter 'num' in the base 'base'. For example, if num=21, and base=2 you would return 3 because the binary representation for 21 is 10101 which has a digit sum of 3. However, if num=62 and base=4 you would return 8 because that is the sum of the digits in base 4. Your solution must be recursive! Note that 'base' will be between 2 and 10 inclusive and 'num' will be a non-negative integer. radSumBase(0, 5) → 0 radSumBase(256, 2) → 1 radSumBase(255, 2) → 8 ...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: 420
Copyright Nick Parlante 2017 - privacy