Deduction of the fast recurrence In the basic recurrence, k is a constant parameter and n varies. So we can write T(n) instead of T(n,k): (1) T(1) = 1, T(n) = 1 + [T(n-1)+k-1] mod n. The sought term is T(N), where N is a given value. Fast recurrence (with line numbers for reference): 1 z(1)=1, r(1)= 1 2 for m>=1: 3 if z(m) e(m)+k-1 9 z(m+1) = z(m) + (z(m) + e(m))/(k-1) 10 r(m+1) = r(m) + e(m) 11 Result for m = M with z(M) <= N < z(M+1): 12 T(N) =r(M) + k(N - z(M)) Definitions: (D1) n is a so-called start number if T(n)<=k-1. (D2) z(m) is the sequence of start numbers. (D3) r(m) = T(z(m)) The basic recurrence leads to (2a) T(n+1) = T(n)+k if T(n)+k<=n+1 and (2b) T(n+1) = T(n)+k-(n+1) if not If d(m)=z(m+1)-z(m)>1, a linear progression (difference k) starts with r(m) according to (2a): (3a) T(z(m)+j) = r(m)+j*k, 0<=j 0 and (5b) q=1 if not This completes lines 7, 8. Lines 11, 12: The recurrence will stop if z(m)<= N < z(m+1). With (3a) and j=N-z(m) we yield the result: T(N) = T(z(m)+j) = r(m)+k*(N-z(m)) Lines 1, 3, 4, 5: As d(m)>=z(m)-z(m) mod(k-1), z(m)>=k-1 is sufficient for d(m)>0. If we fix z(1)=1 as the first start number and r(1)=T(1)=1, we must use the basic recurrence for z(m)