#include <iostream>
usingnamespace std;
int main() {
/* first number is amount of triplet input [A B N];
A is the first value of the sequence,
B is the step size and
N is the number of first values which should be accounted.
calculate the sum of first members of arithmetic sequence.
Sn=n/2(a1 + an); an = a1 + (n - 1)d, */
int a, n, sum, firstnum, lastnum, d;
cin >> a;
for (int i =0; i<a; i++){
cin>> firstnum;
cin>>d;
cin>> n;
lastnum = firstnum + (n-1)*d;
sum = (n/2)*(firstnum + lastnum);
cout << sum<<" ";}
}
Integer division truncates towards zero. 5 / 7 = 0 in integer division. You probably don't want this. I fixed this and the output was the expected output.