TopcoderArchiveVisit Topcoder
SRM12 Jul 2006
SRM 311

SumThemAll

Problem statement, definition, constraints, and public examples.

Problem Statement

Find the sum of all the digits in all the integers between lowerBound and upperBound, inclusive.

Definition

Class:
SumThemAll
Method:
getSum
Parameters:
int, int
Returns:
long
Method signature:
long getSum(int lowerBound, int upperBound)
(be sure your method is public)

Constraints

  • upperBound will be between 0 and 2,000,000,000, inclusive.
  • lowerBound will be between 0 and upperBound, inclusive.

Examples

  1. 0
    3
    Returns: 6
    0 + 1 + 2 + 3 = 6
  2. 10
    14
    Returns: 15
    (1+0) + (1+1) + (1+2) + (1+3) + (1+4) = 15
  3. 0
    0
    Returns: 0
  4. 14
    53
    Returns: 296
  5. 24660
    308357171
    Returns: 11379854844
Back to all problems