TopcoderArchiveVisit Topcoder
SRM26 Mar 2008
SRM 395

SquareDigitNumbers

Problem statement, definition, constraints, and public examples.

Problem Statement

You enjoy working with numbers that contain only square digits (namely, 0, 1, 4 and 9). The sequence containing only these digits is 0, 1, 4, 9, 10, 11, 14... Return the n-th term (indexed from 0) in this sequence.

Definition

Class:
SquareDigitNumbers
Method:
getNumber
Parameters:
int
Returns:
int
Method signature:
int getNumber(int n)
(be sure your method is public)

Constraints

  • n will be between 0 and 1000, inclusive.

Examples

  1. 0
    Returns: 0
    The first square digit number is 0.
  2. 5
    Returns: 11
  3. 16
    Returns: 100
  4. 121
    Returns: 1941
  5. 123
    Returns: 1949
Back to all problems