Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- echo -n "Enter Number : "
- read n
- # store single digit
- sd=0
- # store number in reverse order
- rev=""
- # store original number
- on=$n
- while [ $n -gt 0 ]
- do
- sd=$(( $n % 10 )) # get Remainder
- n=$(( $n / 10 )) # get next digit
- # store previous number and current digit in reverse
- rev=$( echo ${rev}${sd} )
- done
- if [ $on -eq $rev ];
- then
- echo "Number is palindrome"
- else
- echo "Number is NOT palindrome"
- fi
Add Comment
Please, Sign In to add comment