Ejemplo n.º 1
0
int main (void)
{
    int x;
    int y;
    printf("Give me two numbers:");
    scanf("%d%d", &x, &y);
    printf("The result of %d times %d is: %d\n", x, y, multiples(x,y));
    return 0;
}
Ejemplo n.º 2
0
int main() {
	
	int myints[] = {3, 5};
	std::set<int> myset (myints, myints + 2);
	int limit = 1000;
	
	std::cout << multiples(myset, limit) << std::endl;

	return 0;
}
Ejemplo n.º 3
0
int multiples (int number1, int number2)
{
    if (number2 == 1)
    {
        return number1;
    }
    else
    {
        return multiples(number1, number2 - 1) + number1;
    }
}
Ejemplo n.º 4
0
int main(){

  printf("\n");

  printf("Problems from https://projecteuler.net/problems \n\n");

  printf("(1) Multiples of 3 and 5 \n");
  printf("Solution: %d \n\n",multiples());

  printf("(6) Sum Square Difference \n");
  printf("Solution: %d \n\n",sum_sq());

  return 0;

}
Ejemplo n.º 5
0
std::string Problem001::get_answer() {
    std::vector<int> multiples(999);
    std::iota(std::begin(multiples), std::end(multiples), 1);
    multiples.erase(std::remove_if(multiples.begin(), multiples.end(), [](int i)->bool {return i % 3 != 0 && i % 5 != 0;}), multiples.end());
    return std::to_string(std::accumulate(multiples.begin(), multiples.end(), 0));
}