while and for loop example

//int x = 0;

void setup() {
  fill(0);
  size(400,400);
}

void draw() {
 background(255,255,255);
 
 /*
 x = 0;
 while(x < width && mouseX > 0) {
   rect(x,0,mouseX/2,height);
   x = x + mouseX;
   println(x);
 } 
 */
 
 for (int x = 0; x < width && mouseX > 0; x = x+mouseX) {
     rect(x,0,mouseX/2,height);
 }
}