Solved CommonPrimeDivisors in java