You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
530 B
C++

#include <iostream>
int getSumOfMultiplesWithMaxLimit(int base,int max){
int sum = 0;
for (int multiplier = 0, result = 0; result <= max; ++i )
{
result = base * multiplier;
if(result <= max)
sum += result;
}
return
}
int main(int argc, char const *argv[])
{
int result = getSumOfMultiplesWithMaxLimit(3,1000) + getSumOfMultiplesWithMaxLimit(5,1000) - getSumOfMultiplesWithMaxLimit(15,1000);
cout.write("Result: "+result);
return 0;
}