Skip to content

Instantly share code, notes, and snippets.

@dgodfrey206
Created February 10, 2026 15:49
Show Gist options
  • Select an option

  • Save dgodfrey206/688ec11b01df55540180772bfb2d53e0 to your computer and use it in GitHub Desktop.

Select an option

Save dgodfrey206/688ec11b01df55540180772bfb2d53e0 to your computer and use it in GitHub Desktop.
Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
#include <bits/stdc++.h>
#include <cassert>
using namespace std;
int main() {
int n = 100;
int result = (n * (n + 1) * (3 * n * (n + 1) - 2 * (2 * n + 1)))/12;
cout << result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment