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
#include
#include
int main()
{
int x,y,n;
int sum=0;
printf("enter the valeus of x,y and z\n");
scanf("%d%d%d",&x,&y,&n);
printf("entered valeus of x=%d,y=%d and z=%d\n",x,y,n);
sum=x*((n/x)*((n/x)+1)/2)+y*((n/y)*((n/y)+1)/2)-x*y*(n/(x*y))*((n/(x*y))+1)/2;
printf("sum is %d\n",sum);
return 0;
}
// give x,y and n as 3 5 and 1000