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

 

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

Unfortunately, Gandalf was not present at one of the wizard workshops. This is why he was (temporarily) defeated by the Balrog. If he had attended the workshop he would have found out that the Balrog can be defeated by listing the LEAST SIGNIFICANT digit of a given number in EACH of the bases, 2 through 10. For example, the number 37, when written in base 2 ends with a 1 in the least significant position. It likewise ends in a 1 in base 3, 4, 6, and 9. It ends in a 2 in bases 5 and 7, ends in a 5 in base 8, and of course ends in a 7 in base 10. For any positive input parameter, return a string of the LEAST SIGNIFICANT digits in bases 2 through 10, with commas in between, but no comma at the end. Success will allow future wizards to defeat the Balrog! (Look at the test data for further examples)


balrogNumbers(37) → "1, 1, 1, 2, 1, 2, 5, 1, 7"
balrogNumbers(4) → "0, 1, 0, 4, 4, 4, 4, 4, 4"
balrogNumbers(125) → "1, 2, 1, 0, 5, 6, 5, 8, 5"

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

public String balrogNumbers(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