TopcoderArchive
Archive
Algorithm problem

SquareVerification

Problem statement, definition, constraints, and public examples.

Problem Statement

You have received an integer x from a transmission. Now the sender requests you to send him back a specific integer d obtained from x so that he could verify whether the transmission was correct. In order to find d, you first need to calculate y = x*x and then to find the largest digit of y in decimal notation.

Given an int x, return the value of d.

Definition

Class:
SquareVerification
Method:
calculateCode
Parameters:
int
Returns:
int
Method signature:
int calculateCode(int x)
(be sure your method is public)

Constraints

  • x will be between 1 and 10,000, inclusive.

Examples

  1. 2
    Returns: 4
    2*2 = 4. 4 contains only one digit : 4.
  2. 13
    Returns: 9
    13*13 = 169.
  3. 766
    Returns: 8
  4. 777
    Returns: 9
  5. 1111
    Returns: 4
Back to all problems