Print out number x followed by everything in the range of 1 to (x - 1)
The first is a pretty straightforward for loop with modular arithmetic, skipping 0:


The problem in this code is that you are mixing output with the algorithm logic.


  The second (and, as a disclaimer, I will almost certainly not be using this in actual production code, I wrote it more for my own learning), is based on closures:


I vouch for your decision. This code while might be interesting it has a behaviour that is hard to follow. You basically implemented something that looks like an IEnumerable. However in this code you return a function and what that function does is not documented. You don't know how many times you have to call it.

The solution is then resolving the first problem while using the IEnumerable mechanism that is understood by everyone and has a more comprehensible use:

public static IEnumerable&lt;int&gt; RollAround(int n)
{
    if(n &lt; 1)
    {
        throw new ArgumentException("n must be greater or equal to 1", nameof(n));
    }

    var elems = new[] { n };
    return elems.Concat(Enumerable.Range(1, n - 1));
}

static void Main(string[] args)
{
    foreach(var elem in RollAround(3)){
        Console.WriteLine(elem);     
    }
}