If you then diagonalize that connection matrix, you can get constant time (though you might have to make a special case for starting at the `5` key):
"Diagonalization can be used to efficiently compute the powers of a matrix..." [1]
[1] https://en.wikipedia.org/wiki/Diagonalizable_matrix#Applicat...