Powers of Two Using Bitshift

This simple program is suppose to print out powers of two using the Bitshift operator. I’m expecting an output of 1, 2, 4, 8, 16, 32, but instead get 0, 1, 2, 4, without the 8, 16 and 32.
I must be overlooking something really simple. Any suggestions?

void setup() {
  Serial.begin(9600);
}

void loop() {
  for (int x = 0; x < 6; x = (1 << x))  {
    Serial.print(x);
    Serial.print(", ");
  }
  Serial.println();
  delay(1000);
}

Yes. Get out a pencil and paper and work out what the value of x would be each time through the loop.

but instead get 0, 1, 2, 4,

Hint:

 x < 6;

I don’t expect x to be greater than 5.

OK, I didn't realize that x is tested both before and after the shift. I need to rethink how to handle this.

Try something like:

  for (int x = 0; x < 6; x++)
  {
    Serial.print(1<<x);
    Serial.print(", ");
  }