Hi I wrote this code to print out factors of an integer with a for looop
how do i write it with a while loop?
for(int i = 1; i < integer+1; i++) {
int i = 1; while (i < integer+1) { if(integer % i == 0) cout<< i<<" "; i++; }
Or even better:
int i = 0; while (++i < integer+1) { if(integer % i == 0) cout<< i<<" "; }