• + 0 comments

    java

        public static int getTotalX(List<Integer> a, List<Integer> b) {
        Integer start = Collections.max(a);
        Integer finish = Collections.max(b);
        int counter = 0;
        for (int i = start; i <= finish; i++) {
            final int j = i;
            int count1 = (int)a.stream().filter(element -> j % element == 0).count();
            int count2 = (int)b.stream().filter(element -> element % j == 0).count();
            if (count1 == a.size() && count2 == b.size()) {
                ++counter;
            }
        }
        return counter;
        }