solve permuted multiples problem