全部博文(68)
分类: C/C++
2011-04-26 22:13:27
问题:
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.
答案:233168
#include
int main(void)
{
int sum=0, i=0, k=1000;
for(i=3; i
for(i=5; i
sum+=i;
printf("The answer is %d .\n", sum);
return 0;
}