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

 

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

Write a method that returns the GREATEST sum of all the digits in 'num' when 'num' is written in any base from 2 through 10. As preconditions you may assume that 'num' is non-negative. You may copy and paste your solution from the SL problem on THIS test or use any part of that code to help you. For example, if 'num' is 55 you would return 13 since of all the bases from 2 to 10, the one with the greatest sum of digits is base 8 in this case. This is because 55, written in base 8, is "67" (base 8), which has a sum of 13. If you write 55 in any of the other possible bases (2 through 10), it will have a smaller digit sum. Note that which base produces the greatest digit sum will change based on the value if 'num'. Do NOT assume that it will always be base 8! Look at the test data for other examples.


test2023_11_16_HL_greatestSumDigits(11) → 6
test2023_11_16_HL_greatestSumDigits(12) → 6
test2023_11_16_HL_greatestSumDigits(13) → 7

...Save, Compile, Run (ctrl-enter)

public int test2023_11_16_HL_greatestSumDigits(int num) { }

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: 290

Copyright Nick Parlante 2017 - privacy