• + 0 comments

    Here is my python code

    def getNextConsideredInt(a, sup):
        """
        Fonction used to get the next considered int thanks to the vector a.
        The parameter sup is the max of vector b.
        This algorithm takes all int between 1 and the sup + 1:
            -> for each "value" it verifies if it is a factor of all numbers of the vector a.
            If this condition is verified, yield the "value"
            -> Instead of starting from 1, it directly stats from the max of a.
        """
        firstval = max(a)
        for value in range(firstval, sup+1):
            # For else condition : Really important here
            for element in a:
                if value%element:
                    break
            else:
                yield value
            
    def vectorDiviseInt(vector, intElement):
        """
        For each element in the vector b, if element%consideredInt != 0, return false    
        """
        for e in vector:
            if e%intElement:
                return 0
        return 1
    
    def getTotalX(a, b):
        nb_vals = 0
        for consInt in getNextConsideredInt(a, max(b)):
            nb_vals += vectorDiviseInt(b, consInt)
        return nb_vals