namespace Bai_so3
{
class Program
{
static void Main(string[] args)
{
int tong = 0, n = 0, x = 0;
Console.Write("Ban nhap vao x=");
x = int.Parse(Console.ReadLine());//7
do
{
//S=1+2+3+...+n;
n = n + 1;//1 2 3 4
tong = tong + n;//1 3 6 10
}
while (tong < x);
Console.WriteLine("n la {0}",n);
Console.WriteLine("Luc nay tong la {0}", tong);
Console.ReadLine();
}
}
}
ngon :3
ReplyDelete