The code I used is as below:
The result is 25164150.#include <iostream> using namespace std; int main (int argc, char * const argv[]) { cout << "PROJECT EULER PROBLEM 6\n" << endl; int start(1), end(100), sum(0), squareSum(0), sumSquare(0); for (int i = start; i <= end; ++i) { int square = i * i; squareSum += square; sum += i; } sumSquare = sum * sum; cout << sumSquare - squareSum << endl; return 0; }
No comments:
Post a Comment