try this code:
public static IEnumerable<int> GetRandom()
{
var rand = new Random();
while (true)
{
yield return
rand.Next(.01, 3);
}
}
public static List<int> GetThirtyThatAddToTwoHundred()
{
do
{
var current = GetRandom().Take(1000);
if (1500 == current.Sum())
{
return current.ToList();
}
} while (true);
}
**taken from StackOverFLow **