id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > radSumBase
prev  |  next  |  chance

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)

public int radSumBase(int num, int base) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 420

Copyright Nick Parlante 2017 - privacy