So my code works, but I want to break out of my loop when the counter is a multiple of 2, 3, and 5, which is when it equals to 30. However when I compile it I want to display to the screen that 30 is a multiple of 2 3 and 5. Also the way I used the break seemed kind of a cheap way to do it, is there another way I can break the loop when it is the 3 multiples? Thanks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
usingnamespace std;
int main()
{
int counter = 0;
while (1)
{
counter += 1;
if (counter > 30)
break;
cout << "current counter value:" << counter << "\n";
}
}