text: D Numbers | C ++ implementation for the above approach ; Function to find the N - th icosikaipentagon number ; number should be greater than 3 ; Check every k in range 2 to n - 1 ; condition for D - Number ; Driver Code
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; int isDNum ( int n ) { if ( n < 4 ) return false ; int numerator , hcf ; for ( int k = 2 ; k <= n ; k ++ ) { numerator = pow ( k , n - 2 ) - k ; hcf = __gcd ( n , k ) ; } if ( hcf == 1 && ( numerator % n ) != 0 ) return false ; return true ; } int main ( ) { int n = 15 ; int a = isDNum ( n ) ; if ( a ) cout << " Yes " ; else cout << " No " ; }