Run if (or similar) statement once

mdpm appears to be only an intermediate value. Plug the other side of the equal sign into the equation on the following line, and the reason that rpm is 0 just might become obvious.