Write a program that reads several integers and prints whether they are palindrome or not. A number is palindrome if it is unchanged after being reversed. The number 616 is palindrome. The number 1234 is not palindrome.
Input will consist of several lines each with a number n where 0 ≤ n ≤ 1 000 000 000.
For each line of input, output should contain a single line with one of the following two messages:
<n> is palindrome
, if the number n is palindrome;<n> is not palindrome
, if the number n is not palindrome;either with <n>
replaced by the number n.
616
1234
789987
616 is palindrome
1234 is not palindrome
789987 is palindrome
palindrome
functionYour program should be implemented using a palindrome
function
that receives one integer and
returns a boolean value indicating whether it is palindrome.
Please refer to the information for the chosen language:
def palindrome(x):
int palindrome(int x);
palindrome :: Int -> Bool
bool palindrome(int x);
public static bool Palindrome(int x)
in a public class Program
public static boolean palindrome(int x)
in a public class DigitPalindrome
function palindrome(x)
function palindrome (x)
def palindrome(x)
Submit your solution to be graded according to the following list:
palindrome
functionIf you have difficulty with this exercise, try digit-sum or digit-count first.
try first: digit-reverse oddeven
Copyright © 2020-2022 Rudy Matela
This text is available under the CC BY-SA 4.0 license.
Originally available on cscx.org/digit-palindrome