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.
I have the following code but the answer do
int Sum(int N) {
long long c = 0;
N--; //because you want it less than 1000 if less than or equal delete this line
int n = N/3,b = N/5,u = N/15;
c+= (n*(n+1))/2 * 3;
c+= (b*(b+1))/2 * 5;
c-= (u*(u+1))/2 * 15;
return c;
}