• + 1 comment

    JavaScript

    function getTotalX(a, b) {
        // Write your code here
        let min = a[a.length - 1]; // from the last element of array 1 
        let max = b[0]; // till the first element of array 2    
        let count = 0;
    
        //start looping through these values
        for(let i = min; i <= max; i++) {
            let allAreFactors = a.every(val => i % val == 0);
            let isFacotrToAll = b.every(val => val % i == 0);
            if(allAreFactors && isFacotrToAll) count++;
        }
        return(count);
    }