A recursive formula for a(n) in sequence A007495 k: number of persons (1<k<=n); n: counting period. s(k,n): number of survivor; result: a(n) = s(n,n) The second line in the following table shows the order of k persons after the first victim, say number x, has been removed. The counting is continued with number x+1. The first line presents the initial order of k-1 persons: k-1: 1 2 .. k-x+1 k-x+2 k-x+3 .. k-2 k-1 k : x+1 x+2 .. k 1 2 .. x-2 x-1 If n = 0 mod k: x = k; else: x = n mod k. Merged: (1) x = 1 + (n-1) mod k For cyclic reasons, s(k-1,n) and s(k,n) must be placed in the same column. This creates s(k,n) = 1 + (s(k-1,n) + x - 1) mod k Inserting formula (1): (2) s(k,n) = 1 + (s(k-1,n) + n - 1) mod k The recursion starts with s(1,n) = 1 and ends with a(n) = s(n,n). The transformation t(j,n) = s(j,n)-1 for 1<=n<=n creates a more compact version of (2): (3) t(k,n) = (t(k-1,n) + n) mod k t(1,n) = 0; a(n) = t(n,n) + 1 Example: n=4 n=5 t(1,4) = 0 t(1,5) = 0 t(2,4) = (0+4) mod 2 = 0 t(2,5) = (0+5) mod 2 = 1 t(3,4) = (0+4) mod 3 = 1 t(3,5) = (1+5) mod 3 = 0 t(4,4) = (1+4) mod 4 = 1 t(4,5) = (0+5) mod 4 = 1 t(5,5) = (1+5) mod 5 = 1 Result: a(4) = t(4,4) + 1 = 2 Result: a(5) = t(5,5) + 1 = 2 Remark: To obtain the result, n calculation steps are needed. The direct counting method needs n(n-1) steps to determine the survivor: n steps respectively to eliminate each of the first n-1 victims. There is indeed a shortcut (the first victims are n,1,3,6,10, ..,j(j-1) < n) but, if n is large, only a small fraction of victims (j^2=O(n)) can be predicted that way so that the number of counting steps remains O(n^2).