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 ) ) ); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter