loop for each bit
while ( num_of_bits >= 0 ) : NEW_LINE INDENT if ( N & ( 1 << num_of_bits ) ) : NEW_LINE INDENT r += ( "1" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT r += ( "0" ) ; NEW_LINE DEDENT num_of_bits -= 1 NEW_LINE DEDENT return r ; NEW_LINE def NBitBinary ( N ) : NEW_LINE r = [ ] NEW_LINE first = 1 << ( N - 1 ) ; NEW_LINE last = first * 2 ; NEW_LINE