A simple little cheat way is to wait for button release, then wait for button press at the start of your code:
digitalWrite(ledPin,HIGH); // Set the idle state
while(digitalRead(buttonPin)==HIGH); // Wait for a release, if it is pressed.
while(digitalRead(buttonPin)==LOW); // Wait for button to be pressed.
for (int i=0; i <= numberOfPulses; i++)
// set the LED on
Of course, this doesn't fit well with a state machine if you ever want to expand your code to do other things. If this is all it will do then this method is fine.