• + 0 comments
    public static int getTotalX(List<int> a, List<int> b) {
      List<int> result = [];
      for (var i = a.Last(); i <= b.Last(); i++) {
        var isFactorOfA = a.Select(s => i % s).All(v => v == 0);
        var isFactorOfB = b.Select(s => s % i).All(v => v == 0);
    
        if (isFactorOfA && isFactorOfB) result.Add(i);
      }
    
      return result.Count;
    }