Check whether a number is PALINDROME or Not | faceprep

Check whether a number is PALINDROME or Not | faceprep

The program to check whether the given number is a palindrome or not is discussed here. Check below for the full code in different programming languages!


check-whether-a-number-is-palindrome-or-not-in-c-c-java-and-python-faceprep


Any number is said to be a palindrome if the original number and the reverse of the original number are the same.

For example, 1234321 is a palindrome.nnOriginal number = 1234321nThe reverse of the number = 1234321n




check-whether-a-number-is-palindrome-or-not-in-c-c-java-and-python

Algorithm to check whether a number is a palindrome or not

  • Input the number.
  • Find the reverse of the number.
  • If the reverse of the number is equal to the number, then return true. Else, return false.

A number can be checked if it is a palindrome or not in both iterative and recursive approaches. Both approaches are discussed below.




check-whether-a-number-is-palindrome-or-not-in-c-c-java-and-python

Palindrome or not using an iterative approach


@@coding::1@@


Time complexity: O(n)



Palindrome or not using a recursive approach


@@coding::2@@


Time complexity: O(n)


Recommended Programs

Leap year or not

Prime number or not

Armstrong number or not

Strong number or not

Perfect number or not

Friendly pair or not (amicable or not)

Automorphic number or not

Harshad number or not

Abundant number or not




check-whether-a-number-is-palindrome-or-not-in-c-c-java-and-python

c