List P to store the base k representation of the number
int [ ] p = new int [ String . Join ( " " , n ) . Length + 2 ] ; int index = 0 ; int x = n ; int j ; while ( x > 0 ) { p [ index ] = ( int ) ( x % k ) ; x /= k ; index ++ ; } int idx = 0 ; for ( int i = 0 ; i < p . Length - 1 ; ++ i ) { if ( p [ i ] >= 2 ) {