Esempio n. 1
0
int main(int argc, char *argv[]) {
	int number = 1000;
	
	// We sum up the multiples of 3 and 5 inside 1000 and then we extract the commons (multiples of 15)
	int result = sumMultiples(number - 1, 3) + sumMultiples(number - 1, 5) - sumMultiples(number - 1, 15);
	
	std::cout << result;
}
Esempio n. 2
0
int main() 
{
    int testCases = 0, limit = 0;
    
    // testCases consumes the first input (in this implementation)
    scanf("%i", &testCases);    

    //as long as we're reading in test cases
    while(scanf("%d", &limit) == 1)
    {
    	// print the sum of 3 and/or 5 multiples less than the specified limit
        printf("%d\n", sumMultiples(limit));
    }
    return 0;
}