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