• + 1 comment

    Thanks for this solution! I realized that int i=min;i<=max;i++ iterates all the way to the highest value in b, which is unnecessary, as the largest possible factor of values in array b is the smallest value in it. Change int max = b[b.length-1]; to int max = b[0]; and you save a lot of unnecessary work.