Java 代码
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
int a = cin.nextInt();
int n = cin.nextInt();
while (n <= 0)
{
n = cin.nextInt();
}
int sum = 0;
for (int i = a; i < a + n; i ++)
sum += i;
System.out.println (sum);
}
}