HTML & JS
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int t;
	long n, sum = 0;
	cin >> t;
	while(t--){
	    cin >> n;
	    sum = ((n * (n + 1)) * ((2 * n) + 4)) / 12;
	    cout << sum << endl;
	}
	return 0;
}

Generated URL:

Output:

1540
Report Bug