Bash program to check if the Number is a Palindrome

clear
echo "enter a number"
read num
n=$num
rev=0
while [ $num -gt 0 ]
do
r=$(( $num % 10 ))
rev=$(( $rev * 10 + $r ))
num=$(( $num / 10 ))
done
if [ $n -eq $rev ]
then
echo "palindrome number"
else
echo "not palidrome"
fi

output:-



Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post