Given a number N, output/return X so that N+X is a palindrome, where |X| has to be as small as possible.
Palindrome: A number is a palindrome, if its sequence of digits is the same when reading them from left to right as when reading from right to left.
6548456 are symmetric,
2424 are not. Numbers with leading zeros such as
020 are not a palindrome.
Input is a positive integer smaller than 1015. Read it from stdin, as a method-parameter, whatever.
Output has to be an integer (positive or negative) and ought to be 0 if the input is already a palindrom. You may write your output to stdout, return it from a function or whatever you like. If there are 2 numbers (e.g.
-2) that satisfy the requirements, output only one of them.
Input Output 3 0 234 -2 1299931 -10 126 5 or -5 (only one of them)