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

 

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

Write a method that returns the "distilled" version of an integer parameter. "Distilling" a number involves the following process: Start with a positive integer. Divide that number by the sum of its digits, keeping the integer part of the result. Continue this process until the result is less than 100, or until the result is the same as the number than came before it. For example, when you divide 1000 by the sum of its digits you get 1000, so that is the distilled version of the number. Note that an input parameter that is already less than 100 will just be returned as the result.


distilNum(324879) → 26
distilNum(1248941) → 23
distilNum(10000) → 10000

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

public int distilNum(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: 430

Copyright Nick Parlante 2017 - privacy