• + 0 comments

    PHP one more

    function getTotalX(array $a, array $b):int {
        $res=0;
        for($i=end($a);$i<=$b[0];$i++) {
            $count1=0;
            $count2=0;
            for($j=0;$j<count($a);$j++){   
                $i % $a[$j] === 0 ? $count1++ : '';
            }
    
            for($j=0;$j<count($b);$j++){
                $b[$j] % $i == 0 ? $count2++ : '';
            }
            
            if($count1 == count($a) && $count2 == count($b)) {
                $res++;
            }
        }
        return $res;
    }