It is pretty simple.
The number will be printed only if M(Q-1) returns 0 , and this happens when the value of Q is 7 .
And about zeros, this is because you are asking printf to print the number at the three positions of the print zeros at the beginning. printf("%03d\n", Q); More details here .
source share