#include <iostream>
using namespace std;
I am very new to cpp and programming and I am trying to find the factors of a number, max
, why is my code output coming out the way it is?
int max;
cout << "Enter a number you'd like to see the divisors of: " << endl;
cin >> max;
//I am trying to find all divisors for the number max
//I know this isn't the most efficienct way but I thought that it would work.
//Instead of 50, 25, 20, 10, 5 ,1 for output it looks like 50, 25, 25, 25 25, 5
for (int t=1; t <= max; t++) {
if (max % t == 0) {
int m = max/t;
}
}
cout << m << endl;