The equation in the code is equivalent to this ...
rpm = 60 * 1000 * rpmcount / (millis() - timeold);
Ray