Push Button Counters/Modulo Question

Greetings Im trying to teach myself Arduinos, and have been sifting through the tutorials and trying to learn the code and then rewrite my own. I got to the one about using a Push button to turn on a LED every 4 clicks: http://arduino.cc/en/Tutorial/ButtonStateChange. I thought I would try and be clever and modify it to use 4 LEDs, each coming on one at a time with one click, then all going off and starting again. (So click once: just Green Led, click twice: just White LED, thrice: jsut a blue LED, 4 times: just a Orange LED, 5 times: No LEDS).

I didnt really understand the last section of example code about how it knows to work only every forth time. So i took a whild stab in the dark changed a the numbers after the % to see what happens.

const int ButtonIn = 2;

const int GreenLED = 9;
const int WhiteLED = 6;
const int BlueLED = 5;
const int OrangeLED = 3;

int PushCounter = 0;
int ButtonState = 0;
int ButtonStateLast =0;

void setup(){
  pinMode (ButtonIn, INPUT);
  pinMode (GreenLED, OUTPUT);
  pinMode (WhiteLED, OUTPUT);
  pinMode (BlueLED, OUTPUT);
  pinMode (OrangeLED, OUTPUT);
  Serial.begin (9600);
}

void loop() {
  ButtonState = digitalRead(ButtonIn);
  
  if (ButtonState != ButtonStateLast) {
    if (ButtonState == HIGH) {
      PushCounter++;
      Serial.println ("On");
      Serial.print ("Number of Button Pushes: ");
      Serial.println (PushCounter, DEC);
    }
    else {
      Serial.println ("Off");
    }
  }
  ButtonStateLast = ButtonState;
  
  if (PushCounter % 5 == 0) {
    digitalWrite (GreenLED, HIGH);
    digitalWrite (WhiteLED, LOW);
    digitalWrite (BlueLED, LOW);
    digitalWrite (OrangeLED, LOW);
  }
    
  else if (PushCounter % 5 == 1) {
    digitalWrite (GreenLED, LOW);
    digitalWrite (WhiteLED, HIGH);
    digitalWrite (BlueLED, LOW);
    digitalWrite (OrangeLED, LOW);
  }
    
  else if (PushCounter % 5 == 2) {
    digitalWrite (GreenLED, LOW);
    digitalWrite (WhiteLED, LOW);
    digitalWrite (BlueLED, HIGH);
    digitalWrite (OrangeLED, LOW);  
  }
  
   else if (PushCounter % 5 == 3) {
    digitalWrite (GreenLED, LOW);
    digitalWrite (WhiteLED, LOW);
    digitalWrite (BlueLED, LOW);
    digitalWrite (OrangeLED, HIGH);
   }
    
    else {
    digitalWrite (GreenLED, LOW);
    digitalWrite (WhiteLED, LOW);
    digitalWrite (BlueLED, LOW);
    digitalWrite (OrangeLED, LOW);
    }
}

What it does is flash each one in turn very quickly, then if you press the button it freezes at which ever LED is lit at that time. This would eb great if i was designing a reaction tester, but not what I had in mind. Is anyone able to explain any of this to me please?

Ha found it myself. I checked the serial monitor and thought " I have seen this behaviour before.." What do you know, i had put the pull down resistor into the wrong hole in the breadboard, and the input was floating. I plugged it in the right place and hey it works perfectly.

I look forward to bringing you an actual challange some day!

Thanks for looking.. :D