Skip navigation

This was also very simple, execution was immediate:

#include <iostream>
#include <math.h>

int main (int argc, char * const argv[]) {
    const unsigned int limit = 101;
    int i;
    unsigned long long sumOfSquares = 0; 
    unsigned long long squareOfSums = 0;
    long long diff;
    for(i=1;i<limit;i++){
      sumOfSquares += pow((i),2);
      squareOfSums += i;
    }
    squareOfSums = pow(squareOfSums, 2);
    diff = squareOfSums - sumOfSquares;
    std::printf("Sum of Squares: %llu Square Of Sums: %llu the difference: %llu \n", sumOfSquares, squareOfSums, diff);
    return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: