Skip to content

Instantly share code, notes, and snippets.

@thecoducer
Created August 3, 2019 18:28
Show Gist options
  • Save thecoducer/47e6cc2220f5a8dd49e7c639c7505e1a to your computer and use it in GitHub Desktop.
Save thecoducer/47e6cc2220f5a8dd49e7c639c7505e1a to your computer and use it in GitHub Desktop.
#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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment