At a particular time , we have to decide whether we have to print ' A ' or ' B ' , this can be check by calculating the value of pow ( 2 , k - 1 )
while ( k > 0 ) { num = ( int ) Math . Pow ( 2 , k - 1 ) ; if ( num >= N ) Console . Write ( " A " ) ; else { Console . Write ( " B " ) ; N -= num ; } k -- ; }