Finding n | CPP program to find n - th number with prime digits 2 , 3 and 7 ; remainder for check element position ; if number is 1 st position in tree ; if number is 2 nd position in tree ; if number is 3 rd position in tree ; if number is 4 th position in tree ; Driver code
#include <algorithm> NEW_LINE #include <iostream> NEW_LINE #include <string> NEW_LINE using namespace std ; string nthprimedigitsnumber ( int number ) { int rem ; string num ; while ( number ) { rem = number % 4 ; switch ( rem ) { case 1 : num . push_back ( '2' ) ; break ; case 2 : num . push_back ( '3' ) ; break ; case 3 : num . push_back ( '5' ) ; break ; case 0 : num . push_back ( '7' ) ; break ; } if ( number % 4 == 0 ) number -- ; number = number / 4 ; } reverse ( num . begin ( ) , num . end ( ) ) ; return num ; } int main ( ) { int number = 21 ; cout << nthprimedigitsnumber ( 10 ) << " STRNEWLINE " ; cout << nthprimedigitsnumber ( 21 ) << " STRNEWLINE " ; return 0 ; }