Sort by

recency

|

3015 Discussions

|

  • + 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;
        }
    
  • + 0 comments

    def getTotalX(a, b): numbers_between = [] condition_1_flag = 0 condition_2_flag = False main_list = a+b max = max(main_list)

        for i in range(1,max+1):
                condition_1_flag = 0
                condition_2_flag = 0
                for item in a:
                        if i%item == 0:
                                condition_1_flag+=1
                        if condition_1_flag == len(a):
                                numbers_between.append(i)
                for item in b:
                        if item%i == 0:
                                condition_2_flag+=1
                        if condition_2_flag == len(b):
                                numbers_between.append(i)
    
    
        numbers_between.sort()
    

    def find_repeated_numbers(arr): count_dict = {} repeated_numbers = []

    # Count occurrences of each number
    for num in arr:
        if num in count_dict:
            count_dict[num] += 1
        else:
            count_dict[num] = 1
    
    # Find numbers that are repeated
    for num, count in count_dict.items():
        if count > 1:
            repeated_numbers.append(num)
    
    return len(repeated_numbers)
    
  • + 0 comments

    in python

    def getTotalX(a, b):
        mcm_a = math.lcm(*a)
        i=1
        counter = 0
        while i*mcm_a <= min(b):
            div_b = True
            for b_ in b:
                if b_%(i*mcm_a)!=0:
                    div_b = False
            if div_b == True:
                counter+=1
            i+=1
        return counter
    
  • + 0 comments

    Here is my c++ solution, you can see the explanation here : https://youtu.be/Xgchif6uHDU

    #include <bits/stdc++.h>
    
    using namespace std;
    
    int gcd(int a, int b){
        if(b == 0) return a;
        return gcd(b, a%b);
    }
    
    int lcm(int a, int b){
        return a * b / gcd(a,b);
    }
    
    int main() {
        int n, m, e, l = 1, g = 0;
        cin >> n >> m;
        for(int i = 0; i < n; i++){
            cin >> e;
            l = lcm(l, e);
        }
        for(int i = 0; i < m; i++){
            cin >> e;
            g = gcd(g, e);
        }
        int res = 0;
        for(int c = l; c <= g; c+=l)if(g % c == 0) res ++;
        cout << res;
        return 0;
    }
    
  • + 0 comments

    can i use this script in my website page . i have wordpress website and a want to add this in one of my website page : https://capcuttemplatestore.com/trending-templates/