using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
public class Program
{
static void Main(string[] args)
{
int n, m, result;
string chars = "Y";
bool test;
do
{
Console.WriteLine("===============從1加到N的和===============");
Console.WriteLine("請輸入壹個數字!");
test = int.TryParse(Console.ReadLine(), out n);
if (test == true)
{
result = n * (n - 1) / 2 + n;
Console.WriteLine("和為:{0}", result);
Console.ReadLine();
}
else
{
Console.WriteLine("請不要輸入非法字符!");
chars = Console.ReadLine();
}
} while (chars == "N");
}
}
}