Skip to content

Instantly share code, notes, and snippets.

@esn89

esn89/gist:4657542

Created Jan 28, 2013
Embed
What would you like to do?
#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