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.
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
2
Returns: 4
2*2 = 4. 4 contains only one digit : 4.13
Returns: 9
13*13 = 169.766
Returns: 8
777
Returns: 9
1111
Returns: 4