Answers for "simple java program for palindrome number"

1

Java program to check palindrome number using recursion

// Java program to check palindrome number using recursion
public class PalindromeNumberRecursion
{
   static int palindromeRecursion(int number, int temp)
   {
      if(number == 0)
         return temp;
      // storing reverse of a number
      temp = (temp * 10) + (number % 10);
      return palindromeRecursion(number / 10, temp);
   }
   public static void main(String[] args)
   {
      int number = 141;
      int temp = palindromeRecursion(number, 0);
      if(temp == number)
      {
         System.out.println("number is palindrome.");
      }
      else
      {
         System.out.println("number is not palindrome.");
      }
   }
}
Posted by: Guest on February-19-2021

Code answers related to "simple java program for palindrome number"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language