text: Palindromic divisors of a number | C # program to find all the palindromic divisors of a number ; Function to check is num is palindromic or not ; Convert n to String str ; Starting and ending index of String str ; If char at s and e are not equals then return false ; Function to find palindromic divisors ; To sore the palindromic divisors of number n ; If n is divisible by i ; Check if number is a perfect square ; Check divisor is palindromic , then store it ; Check if divisors are palindrome ; Check if n / divisors is palindromic or not ; Print all palindromic divisors in sorted order ; Driver code ; Function call to find all palindromic divisors
code: using System ; using System . Collections . Generic ; class GFG { static bool isPalindrome ( int n ) { String str = String . Join ( " " , n ) ; int s = 0 , e = str . Length - 1 ; while ( s < e ) { if ( str [ s ] != str [ e ] ) { return false ; } s ++ ; e -- ; } return true ; } static void palindromicDivisors ( int n ) { List < int > PalindromDivisors = new List < int > ( ) ; for ( int i = 1 ; i <= Math . Sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) { if ( isPalindrome ( i ) ) { PalindromDivisors . Add ( i ) ; } } else { if ( isPalindrome ( i ) ) { PalindromDivisors . Add ( i ) ; } if ( isPalindrome ( n / i ) ) { PalindromDivisors . Add ( n / i ) ; } } } } PalindromDivisors . Sort ( ) ; for ( int i = 0 ; i < PalindromDivisors . Count ; i ++ ) { Console . Write ( PalindromDivisors [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int n = 66 ; palindromicDivisors ( n ) ; } }