Generating gray codes for the given number of bits