Counting pulses with Arduino Nano

Printing something every pulse (40000 times per second) can't be seen by humans.
Printing every time when 40 is reached (1000 times a second) also can't be seen by humans.

What are you trying to do.
If the frequency is relatively constant, it makes more sense to count pulses for e.g. one second.
And then display the number of pulses in the serial monitor.
Leo..