Hello everyone this is my first post on the daniweb community.
Currently I am home sick with a nasty cold so I was trying to solve a programming problem on a wonderfull sight called Project Euler.
The problem is as follows:
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
Based on this problem I wrote this piece of code, which returns the value 266,333:
#include <iostream>
using namespace std;
int main()
{
int x = 0;
for(int i = 0; i < 334; i++)
{
x += 3 * i;
}
for(int i = 0; i < 200; i++)
{
x += 5 * i;
}
cout << x << endl;
return 0;
}
However, this answer is wrong and I can not find a problem with my code any suggestions?
Thanks for the help and sorry if my code is not written that well, or sloppy I have just started learning programming for my school robotics team.