Open pangfengliu opened 10 years ago
int main(void) { // your code goes here int a, b; int number; int sum = 0; scanf("%d%d", &a, &b); number = a; while ( number <= b ) { sum += number; number += 1; } printf("%d", sum);
return 0;
}
main() { int i = 1; int sum = 0; int j; scanf("%d", &j); while (i <= j){ sum += i; i++; } printf("%d\n", sum); }
main() { int i, j, sum = 0; scanf("%d", &j); for (i = 1; i <= j; i++) sum += i; printf("%d", sum); return 0; }
Task Description
Write a program to compute the sum from i to j, where i < j, and both i and j are positive integers.
Input Format
There are two lines in the input. The first line has the integer i. The second line has the integer j.
Output Format
There are one line in the output. The line has the sum from i to j.
Sample Input
2 5
Sample Output
14