I'm assuming the question wants us to find integers that are divisible by 3 but not by 9. This can be easily obtained using a mod function inside the following if statement: if(number % 3 == 0 && number % 9 != 0)
Here is a short program I wrote in c++ to show how to solve this problem. Instead of returning the set of integer, I just printed them out on the screen:
#include
#include
using namespace std;
int main(int argc, char** argv)
{
int i = 0;
vector list;
vector::iterator it;
for(i = 1; i <= 100; i++)
{
if(i%3 == 0 && i%9 != 0)
{
list.push_back(i);
}
}
for(it = list.begin(); it != list.end(); it++)
{
cout << *it << endl;
}
return 0;
}
If I missed anything, please let me know. Happy coding and problem solving!