#include using namespace std; int x, results = 0; const int res_per_row = 8; // This assignment is worth 2 points int main() { cout << "Enter a number: "; cin >> x; for(int i = 2; i <= x/2; i++) // You can use i=x/2; i>1; i++ instead { if(x % i == 0) { cout << x/i << ' '; // If you're decrementing the for, then just use i if(++results % res_per_row == 0) cout << endl; } } return 0; }