Solved CountFactors in java