Count of N digit palindromic numbers divisible by 9 | C ++ 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; int countPalindromic ( int n ) { int count ; if ( n % 2 == 1 ) { count = pow ( 9 , ( n - 1 ) / 2 ) ; } else { count = pow ( 9 , ( n - 2 ) / 2 ) ; } return count ; } int main ( ) { int n = 3 ; cout << countPalindromic ( n ) ; return 0 ; }