Sum square difference

Project Euler problem #6 solution in C++:

#include <iostream>
using namespace std;
int main(){
  unsigned long dif=5050*5050; //square of sum of first 100 natural numbers
  for(int i=1;i<101;i++){
    dif-=i*i;
  }
  cout << dif << '\n';
  system(“pause”);
  return 0;
}


Leave a Reply

Name *
Email *
Website