Your circuit should look something like this:

And here is code that will flash an LED whenever a variable is a multiple of 3:
const int led_pin = 5;
int counter = 1;
void setup() {
Serial.begin(9600);
pinMode(led_pin, OUTPUT);
}
void loop() {
// Use an if statement and modulo to determine if
// our number is a multiple of 3
if ( (counter % 3) == 0 ) {
digitalWrite(led_pin, HIGH);
delay(500);
digitalWrite(led_pin, LOW);
} else {
Serial.println(counter);
}
// Increment our counter and wait
counter = counter + 1;
delay(500);
}