(state + 1)
This takes the number representing the current state, and adds 1 to it, since the number representing the state 5 degrees to the left is one greater than the current state, based on how the states were created.
Of course, if the number representing the current state is already at the max value of 71 (72 states, starting at 0), then you don't want it to keep increasing, you want it to move back over to 0. So you use:
(state + 1) % 72
% is the modulus operator, which basically takes the remainder of the first argument divided by the second. In essence, it makes sure the number stays less than the second operator. For example:
5 % 72 = Remainder of 5/72. Since 5/72 = 0r5, 5 % 72 == 5, so it has no effect for most cases.
Now, imagine state == 71.
(71 + 1) % 72 == 72 % 72 == Remainder of 72/72. Since 72/72 = 1, and there is no remainder, then (71+1)%72 == 0.
The other direction is a bit trickier.
(72 + state - 1) % 72
This could be simplified as
(state - 1)
If only it would automatically wrap around when state == -1, but it doesn't. So when it gets to -1, we have to reset it to 71. There are two ways to do this: With an If statement, but this takes an extra command, or with modulo arithmetic:
Always adding 72 to a number before taking that number mod 72 is the same as doing nothing before taking that number mod 72. Since 5/72 == 0r5, and (72 + 5)/72 == 77/72 == 1r5, we can see that the remainder is the same. So by adding 72, we don't change the result in any case... except when state is 0:
(72 + state - 1) % 72 == (72 + 0 - 1) % 72 == 71 % 72 == 71.
The reason we have to add 72 first, is because -1 % 72 == -1. Not useful.
So it automatically wraps back around when trying to turn to the right when you're already at state 0, and it automatically wraps back around when trying to turn to the left when you're already at state 71.