using System.Collections.Generic;
public static void Main()
var terminatingElements = new HashSet<int>{ 7, 9, 11 };
foreach(var x in CountUntilAny(1,terminatingElements))
public static IEnumerable<int> CountUntilAny(int start, HashSet<int> earlyTerminationSet)
if (earlyTerminationSet.Contains(curr))
if (curr == Int32.MaxValue)