finished Josephus-Problem in C#, how to make this more efficient?
List&lt;int&gt; list = new List&lt;int&gt;();
        int iCounter = 1; //always count till the size of the list
        int iWatcher = 1; //always count till the size of k
        for (int i = 1; i &lt;= n; i++)
        {
            list.Add(i);
        }



You can initialize list more elegantly:

List&lt;int&gt; list = Enumerable.Range(1, n).ToList();




For n = 2; k = 1 it runs infinitely?



Your counting and indexing seem ok, but are a little difficult to comprehend. It can be done a lot easier using modular operations:

static int JosSurvivor(int n, int k)
{
  List&lt;int&gt; positions = Enumerable.Range(1, n).ToList();
  int index = k % n - 1; // %n is important for k &gt; n

  while (positions.Count &gt; 1)
  {
    if (index &lt; 0) index += positions.Count;  // when (index + k) % poisitons.Count == 0 then index becomes -1 from the line below
    positions.RemoveAt(index);
    index = (index + k) % positions.Count - 1;
  }

  return positions[0];
}




Another approach building on the same principle is to maintain a fixed array of indices and then left-shift the reminder of the indices for each found index while decrement n by 1:

static int JosSurvivor(int n, int k)
{
  int[] positions = Enumerable.Range(1, n).ToArray();
  int index = k % n - 1;

  while (n &gt; 1)
  {
    if (index &lt; 0) index += n;
    Array.Copy(positions, index + 1, positions, index, n - index - 1);
    n--;
    index = (index + k) % n - 1;
  }

  return positions[0];
}


There seems to be a little performance gain - but not significant.



Yet another version that uses a fixed array of flags, that are set for each found index:

static int JosSurvivor(int n, int k)
{
  int counter = 0;
  int index = -1;
  int runner = 0;
  bool[] positions = new bool[n];

  while (counter &lt; n - 1)
  {
    runner += k;
    int temp = 0;
    do
    {
      index = (index + 1) % n;
    } while (positions[index] || ++temp &lt; k);

    if (runner &gt; 0 &amp;&amp; runner % k == 0)
    {
      positions[index] = true;
      counter++;
    }
  }

  for (int i = 0; i &lt; n; i++)
  {
    if (!positions[i])
      return i + 1;
  }

  throw new InvalidOperationException("No last position found");
}


This is very fast for small ks - even for large ns - but becomes slower when k increases.