http://projecteuler.net/problem=1

#include <stdio .h>
#include <iostream>
 
using namespace std;
 
int main()
{
  int sum = 0;
 
  for(int x = 0; x < 1000; ++x) {
  std::cout << ". ";
  if (x % 3 ==0 || x % 5 == 0) {
    std::cout << x << " ";
    sum += x;
  }
  }
 
  std::cout << "\nSum of numbers which can be divided by 3 and 5 is " << sum << "\n";
  return 0;
};

Leave a Reply