Find if the given number is a Palindrome

A Palindrome is defined as a phrase or a number which when reversed also gives the same phrase or number. For example: 14341 when reversed results in 14341 which is same as the original number. Which is what we call a palindrome.

In order to achieve this, we extend our logic to reverse a given number to add a little condition at the end to check if the created number is equal to the input number or not. If equal it means that the input number was a palindrome, else not.


        public static bool IsPalindromeNumer(int n)
        {
            var reversedNumber = NumberReverse.GetReversedNumber(n);

            if (reversedNumber == n)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        

How it works:

While most of the functionality is fulfilled by the Number Reversal logic, we would just add a condition to check if the reversed number is equal to the original number or not.

Ram
Ram

I'm a full-stack developer and a software enthusiast who likes to play around with cloud and tech stack out of curiosity. You can connect with me on Medium, Twitter or LinkedIn.

Privacy Overview
Referbruv

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Strictly Necessary Cookies

Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.

3rd Party Cookies

This website uses Google Analytics to collect anonymous information such as the number of visitors to the site, and the most popular pages.

Keeping this cookie enabled helps us to improve our website.