I found this code in a website that is meant to echo all powerful numbers between 4 and 1000. I'm not being able to fully understand it! Here is the code
int com = 1000, x, m, k, z;
for (int l = 4; l < com; l++) {
x = l;
m = 3;
k = 0;
z = x;
while (x % 2 == 0) {
x /= 2;
k += 1;
}
while ((m <= x) && (k != 1)) {
k = 0;
while (x % m == 0) {
x /= m;
k += 1;
}
m += 2;
}
if (k > 1)
cout << z << ' ';
}
I did and the program works 100%; I'm just trying to understand how this program works, I tried to trace it for more than 2 hours and didn't get a hold of it.
I read the whole article on Wiki but I still don't get the idea behind this code.