Printing number with for loops in c# - Stack Overflow ( Advanced )


PHOTO EMBED

Thu Nov 12 2020 23:44:51 GMT+0000 (UTC)

Saved by @BrendY99 #cs

using System;
using System.Collections.Generic;

public class Program
{
    public static IEnumerable<int> GetRangeWithInverse( int count ) {
        for (var i = count; i > 0; i--) {
            yield return i;
            if (i > 1) {
                yield return count - i + 1;
            }
        }
    }

    public static void Main()
    {
        Console.WriteLine(string.Join( ',', GetRangeWithInverse( 10 ) ) );
    }
}
content_copyCOPY

https://stackoverflow.com/questions/64813297/printing-number-with-for-loops-in-c-sharp