using System.Collections.Generic;
using System.Threading.Tasks;
namespace Chapter_10_Solution_3
static void GetCombinations(int[] arr, int index, int start, int end)
for (int i = 0; i < arr.Length; i++)
if (i < arr.Length - 1) Console.Write("{0} ", arr[i]);
else Console.Write(arr[i]);
for (int i = start; i <= end; i++)
GetCombinations(arr , index + 1, i , end);
static void Main(string[] args)
Console.Write("Enter N: ");
int n = Int32.Parse(Console.ReadLine());
Console.Write("Enter K: ");
int k = Int32.Parse(Console.ReadLine());
GetCombinations {arr, 0, 1, n);