#include <iostream>
int main() {
int N;
int M;
int sum = 0;
std::cout << "N: ";
std::cin >> N;
std::cout << "M: ";
std::cin >> M;
int *hemming = new int[M - N + 1];
int counter = 0;
for (int i = N; i <= M; ++i) {
if (i % 2 == 0 || i % 3 == 0 || i % 5 == 0) {
std::cout << i << " ";
hemming[counter] = i;
sum += hemming[counter];
++counter;
}
std::cout << std::endl << sum;
#include <iostream>
int main() {
int N;
int M;
int sum = 0;
std::cout << "N: ";
std::cin >> N;
std::cout << "M: ";
std::cin >> M;
int *hemming = new int[M - N + 1];
int counter = 0;
for (int i = N; i <= M; ++i) {
if (i % 2 == 0 || i % 3 == 0 || i % 5 == 0) {
std::cout << i << " ";
hemming[counter] = i;
sum += hemming[counter];
++counter;
}
}
std::cout << std::endl << sum;
}