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

 

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

Write a method that returns the "Strange Digit Sum" of a positive integer. This sum is found by adding the digits of the number, but also adding the amount of the decimal position of that digit. For example, the strange digit sum of 421 is 118 because 1+1 + 2+10 + 4+100 = 118. The 1 is in the 1's place, the 2 is in the 10's place, and the 4 is in the 100's place. So you add the digit and its decimal place, then do that for all of the digits. You are NOT allowed to use any string methods in solving this problem. Recursion would be cool, but is not required.


ggg2StrangeDigitSum(5893223) → 1111143
ggg2StrangeDigitSum(2434) → 1124
ggg2StrangeDigitSum(1) → 2

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

public int ggg2StrangeDigitSum(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