I tried a very simple projecteuler.com problem (the first one, in fact), that went like so:
Find the sum of all multiples of 3 and 5 up to 1,000.
I wrote this brief program to try to do this, as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
int main()
{
int sum = 0;
for (int i = 0; i < 1000; i++)
{
if(sum % 3 == 0 || sum % 5 == 0)
sum += i;
}
std::cout << sum;
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
However, my output at this stage is just 1.
I've looked this whole thing over and can't find the error. Any ideas?