It seems this question has already been answered here.

But honestly, did you write your code in a sleep? It is already summing the factors, so how on earth is it possible that you can't figure out...