int i = 100;
while(i<=7000)
{
int sum = 0,j=0;
string str=i.ToString();
while(j{
sum += str[j] - 48;
if (sum > 7) break;
j++;
}
if (sum == 7) Console.Write(i+",");
i++;
}
Console.ReadKey();
static void Main(string[] args)
{
int i=100;
while (i<=10000)
{
int s = 0;
while (i != 0)
{
s += i % 10;
i /= 10;
}
if(s==7){
Console.WriteLine("{0}", i);}
}
Console.ReadKey();
}