TopcoderArchive
Archive
Algorithm problem

ReverseSums

Problem statement, definition, constraints, and public examples.

Problem Statement

To find the "reverse sum" of a number, we reverse the digits of the number and then add the original number to the reversed number. For example, to find the reverse sum of 1325, first reverse the digits to get 5231. Then, add the original number to get 5231+1325=6556.

Return the reverse sum of the given number N.

Definition

Class:
ReverseSums
Method:
getSum
Parameters:
int
Returns:
int
Method signature:
int getSum(int N)
(be sure your method is public)

Constraints

  • N will be between 1 and 99999, inclusive.

Examples

  1. 1325
    Returns: 6556
    The example from the problem statement. 1325 + 5231 = 6556.
  2. 100
    Returns: 101
    100 + 001 = 101
  3. 89437
    Returns: 162935
    89437 + 73498 = 162935
  4. 1
    Returns: 2
Back to all problems