What is a Palindrome?

Definition

A palindrome is a word, phrase, number, or sequence of words that reads the same backward as forward. It derives from Greek roots that literally mean “running back” (palin is “again, back,” and dromos, “running.”) The word appears to have been created in English based on these roots in the early 1600s.

  • This first known palindrome was in Latin and read “sator arepo tenet opera rotas” which means either:
    • The sower Arepo holds the wheels with effort.
    • The sower Arepo leads with his hand the plough.
  • Palindromes were also found in ancient Greek and in ancient Sanskrit.

Types of Palindromes

Name Palindromes

  • A name that reads the same backward as forward.
  • Examples:
    • Bob, Anna, Hannah, Eve, Elle,

Word and Sentence Palindromes

There are also Word and Sentence Palindromes. E.g. the whole sentence can be read backwards and forwards and be the same.

  • Multiple Word Examples:
    • I did, did I?
    • No lemon, no melon
    • My gym
  • Single Word Example :
    • Civic, Kayak, Level, Madam, Mom, Noon, Race car, Radar, Refer, Rotor, Stats,Tenet,Wow

Number Palindromes

List of Palindrome Numbers in 1 to 10000

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99,

101, 111, 121, 131, 141, 151, 161, 171, 181, 191, 202, 212, 222,

232, 242, 252, 262, 272, 282, 292, 303, 313, 323, 333, 343, 353,

363, 373, 383, 393, 404, 414, 424, 434, 444, 454, 464, 474, 484,

494, 505, 515, 525, 535, 545, 555, 565, 575, 585, 595, 606, 616,

626, 636, 646, 656, 666, 676, 686, 696, 707, 717, 727, 737, 747,

757, 767, 777, 787, 797, 808, 818, 828, 838, 848, 858, 868, 878,

888, 898, 909, 919, 929, 939, 949, 959, 969, 979, 989, 999, 1001,

1111, 1221, 1331, 1441, 1551, 1661, 1771, 1881, 1991, 2002, 2112,

2222, 2332, 2442, 2552, 2662, 2772, 2882, 2992, 3003, 3113, 3223,

3333, 3443, 3553, 3663, 3773, 3883, 3993, 4004, 4114, 4224, 4334,

4444, 4554, 4664, 4774, 4884, 4994, 5005, 5115, 5225, 5335, 5445,

5555, 5665, 5775, 5885, 5995, 6006, 6116, 6226, 6336, 6446, 6556,

6666, 6776, 6886, 6996, 7007, 7117, 7227, 7337, 7447, 7557, 7667,

7777, 7887, 7997, 8008, 8118, 8228, 8338, 8448, 8558, 8668, 8778,

8888, 8998, 9009, 9119, 9229, 9339, 9449, 9559, 9669, 9779, 9889,

9999

What is the longest palindrome word in English?

  • The longest palindromic word in the Oxford English Dictionary is the onomatopoeic tattarrattat, coined by James Joyce in Ulysses (1922) for a knock on the door.

Use of Palindrome Numbers

  • Palindrome Number is very useful in Recreational mathematics topics like Rubik’s Cubes, magic squares, logic puzzles.
  • A palindromic sequence is a nucleic acid sequence on double-stranded DNA or RNA wherein reading 5′ to 3′ forward on one strand matches the sequence reading backward 5′ to 3′ on the complementary strand with which it forms a double helix.
DNA palindrome

https://en.wikipedia.org/wiki/Palindromic_sequence#/media/File:DNA_palindrome.svg

by User:Acdx

C# Program to check if a number is a Palindrome number

  • Logic: If the original number and its reversed numbers are equal. then it is a Palindrome number.
  • Example :
    • 121 & 121 (palindrome number)
    • 144 & 441 (not palindrome number)

Create a new Project

  • Create a new project in Visual Studio.
  • Configure your new project with a name, location and solution file name.
  • Remove unused Namespace.

C# Code to check if a number is a Palindrome number

Copy to Clipboard
  • Here
    • originalNumber Create an integer variable & store a value entered by the user in the console.
    • tempNumber Create a new integer variable to store the value of the original number for calculation.
    • remainder Create a new variable remainder which stores the modulo value
    • reverseNumber” variable will store generated reverse number.
    • Create a while loop which runs only if the original number is bigger than 0.
    • After getting the reverse number, check the condition for Palindrome Number.

Compile, Run & Output

Advanced Version of a Palindrom Software in C#

If you are more curious about what I actually perform step by step then you can write this program with few extra lines for an amazing output.

Copy to Clipboard

Output of Advanced version

Advance code Output

Summary

So now you know what a palindrome is, and how to check with a C# program if a number is a palindrom number. This will come in handy, when it comes to interviews for a job or a university.