Saturday, July 2, 2022

Palindrome Number (Recursion)

 Palindrome Number (Recursion)

Problem Statement
Given a number N, you need to check whether the given number is Palindrome or not. A number is said to be Palindrome when it reads the same from backward as forward.

static boolean isPalindrome(int N)
    {int divisor = 1;
        while (/ divisor >= 10)
            divisor *= 10;
      
        while (!= 0)
        {
            int leading = N / divisor;
            int trailing = N % 10;
      
            
            
            if (leading != trailing) 
                return false;
                N= (% divisor) / 10;
    
            divisor = divisor / 100;
        }
        return true;}

No comments:

Post a Comment

ads vert

Basic HTML Tables - Layout, HTML Tables, Attributes, Aside, Footer, Tr tag, Td tag, Th tag, Tbody

  Basic HTML Tables - Layout, HTML Tables, Attributes, Aside, Footer, Tr tag, Td tag, Th tag, Tbody < table >      < thead >    ...