Nearest Integer – Factor

Nearest Integer – FactorThe program must accept an integer N as the input. The program must print the nearest integer of N based on the following conditions.
– The concatenation of the first digit and the last digit of the integer must be a factor of the same integer.
– If two such integers are equidistant to N, then program must print the smallest integer.

Boundary Condition(s):
100 <= N <= 10^8

Input Format:
The first line contains N.

Output Format:
The first line contains an integer value representing the nearest integer of N based on the given conditions.

Example Input/Output 1:
Input:
103

Output:
105

Explanation:
The nearest possible integer is 105.
The concatenation of the first digit and the last digit in 105 is 15.
15 is a factor of 105.
So 105 is printed as the output.

Example Input/Output 2:
Input:
241

Output:
240

Example Input/Output 3:
Input:
341

Output:
341

Previous Article

Two Teams - Find the Winner

Next Article

Print Cube

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *