Count of N digit palindromic numbers divisible by 9 | Java implementation to count the number of N digit palindromic numbers divisible by 9 ; Function to find the count of N digits palindromic numbers which are divisible by 9 ; If N is odd ; If N is even ; Driver Code
import java . util . * ; class GFG { static int countPalindromic ( int n ) { int count ; if ( n % 2 == 1 ) { count = ( int ) Math . pow ( 9 , ( n - 1 ) / 2 ) ; } else { count = ( int ) Math . pow ( 9 , ( n - 2 ) / 2 ) ; } return count ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( countPalindromic ( n ) ) ; } }