Given a prime p and positive integer k, an integer n with 0≤n<p is called a (p,k)-Hofstadterian residue if there exists an infinite sequence of integers n0,n1,n2,… such that n0≡n and ni+1k≡ni(modp) for all integers i≥0. If f(p,k) is the number of (p,k)-Hofstadterian residues, then compute k=1∑2016f(2017,k).Proposed by Ashwin Sah