Skip to content

Instantly share code, notes, and snippets.

@esn89
Created January 28, 2013 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esn89/4657542 to your computer and use it in GitHub Desktop.
Save esn89/4657542 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main() {
int temp = 0;
int temp2 = 0;
//temp is the sum of the squares
for(int i=1; i<=100; i++) {
temp += i*i;
}
//temp2 accumulates the numbers then squares them later
for(int j=1; j<=100; j++) {
temp2 += j;
}
int answer = (temp2 * temp2) - temp;
cout << answer << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment