><>, 9 8 bytes
Thanks to Sp3000 for saving a byte.
'i$-%n/
There's an unprintable 0x01
before the /
.
Explanation
This is a port of my character code-based Labyrinth answercharacter code-based Labyrinth answer.
' Push the entire program (except ' itself) onto the stack, which ends
with [... 1 47].
i Read the first character of the input.
$- Subtract the 47.
% Take the 1 modulo this value.
n Output the result as an integer.
0x01 Unknown command, terminates the program.