Ok so I have been trying to do project euler problem 1 which finding the sum of all the multiples of 3 and 5 that are less than a thousand. i dont know why my program is not working. here's my program -
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int multiplier3 = 1; // multiplier of 3
int multiplier5 = 1;//multiplier of 5
int mult3 = 0; // multiple of 3
int ans3 = 0; // sum of multiples of 3
int mult5 = 0;//multiple of 5
int ans5 = 0;// sum of multiples of 5
int answer = 0;// sum of the sum of multiples of 3 and the multiples of 5
while (ans3 < 1000){
mult3 = multiplier3 * 3;
ans3 = ans3 + mult3;
multiplier3 = multiplier3 + 1;
mult3 = 0;
}
while (ans5 < 1000){
mult5 = multiplier5 * 5;
ans3 = ans5 + mult5;
multiplier5 = multiplier5 + 1;
mult5 = 0;
}
answer = ans3 + ans5;
cout << answer << endl;
system("PAUSE");
return EXIT_SUCCESS;
}