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.
Can someone give me suggestions on how to improve this solution? Also, please tell me whether or not my programming style is good.
#include<stdio.h>
int main()
{
int a,b,c,d,sum3,sum5,sum15,total_sum;
b=999/3;
c=999/5;
d=999/15;
sum3=b*(3+999)/2;
sum5=c*(5+995)/2;
sum15=d*(15+990)/2;
total_sum=sum3+sum5-sum15;
printf("%d",total_sum);
return 0;
}