答案:233168
// Euler1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
int getSum(int a, int s);
int main(int argc, char* argv[])
{
printf("%d", getSum(3, 999)+getSum(5, 999)-getSum(15, 999));
return 0;
}
// 小于等于s的a的所有倍数之和
int getSum(int a, int s)
{
if(a<s)
{
int n=s/a;
int sum=n*a+n*(n-1)*a/2;
return sum;
}
else
{
return 0;
}
}