Multiples of 3 and 5

#include<stdio.h>

int main(void){
	int n1, n2,n3;
	n1=333*(3+999)/2;
	n2=199*(5+995)/2;
	n3=66*(15+990)/2;
	printf("%d\n",n1+n2-n3);
	n1=getchar();
	return 0;
}

Multiples of 3 and 5

Problem 1

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.

点击打开链接

算法

 

点赞