The K-theory of endomorphisms