Palindrome Numbers | MATLAB Tutorial

Palindrome Numbers | MATLAB Tutorial

Palindrome numbers

What is a palindrome number?

A palindrome is any number that when reversed remains same as it was before being reversed.

For Example:

  • 1001,2002,3003,4004,5005,6006,7007,8008,9009…
  • 1441,1221,1991,2992,2662…
  • 123343321…
  • 9523259…
  • 12321…

Matlab code

x=input('Enter the number : ');
rem= mod(s,10)
res= res*10 + rem;
s = floor(s/10) ;
if res==x
fprintf('%d is a palindrome number',x)
fprintf('%d is not a palindrome number',x)


  1. The user is asked to enter the number which they want to check.
  2. The number is stored in a variable.After that, each of the digits from one’s place to the left is taken.
  3. This is done by using the function named “modulo”.The number is divided by 10 and the remainder is taken.
  4. The user uses a while loop for extracting the digits one by one.
  5. After each number is extracted, it is stored in a variable and it is stored in such a way that it occupies the leftmost part initially and then each number gets stored to the right thereafter.
  6. The while loop should stop when no number can be extracted.
  7. This newly stored number and our original number are then checked.
  8. If both are equal then we  print “It’s a Palindrome”
  9. Else we then print that “It’s not”

This code involves reversing the number first.Secondly, using if statement to check whether the inputted number and the reversed number are same.


Following are some of the output for the code

  • When we enter the number “1001” we get
  • If the entered number is like “34353345”, we get
  • When we enter “3456543”, we get

I am currently pursuing my btech in Electronics and communication engineering from Amrita Vishwa Vidyapeetham. My areas of interest are signal processing, Communication systems, Control system.

Leave a Reply