In the future you need to put your code in the in between the code tags so its easier to read your code and reference line numbers.
I am not sure what your code is supposed to do however, your line if(factor == 1) is almost never true. its outside your second for loop therefore factor gets incremented to a number higher than 1 every time. I think you were trying to put that block of code inside the second for loop. It then might give you some numbers you were hoping for.