public class Solution { public IList> CombinationSum3(int k, int n) { var result = new List >(); Find(1, n, k, new List (), ref result); return result; } private void Find(int start, int target, int k, IList current, ref List > result) { if(current.Count > k || target < 0) { return; } if(target == 0) { if(current.Count == k){ result.Add(new List (current)); } //Console.WriteLine(current); return; } for(var i = start; i < 10; i++) { current.Add(i); Find(i + 1, target - i, k, current,ref result); current.RemoveAt(current.Count-1); } } }