• + 0 comments

    JAVA8 CODE public static int gcd(int x, int y){ if(y==0) return x; return gcd(y, x%y); } public static int lcm(int x, int y){ return x*y/gcd(x,y); }

    public static int getTotalX(List<Integer> a, List<Integer> b) {
    // Write your code here        
      int count =0;
      int Lcm = a.get(0);
      for(int i =0;i<a.size();i++){
        Lcm= lcm(Lcm,a.get(i));
      }
      int Gcd=b.get(0);
      for(int i =0;i<b.size();i++){
        Gcd=gcd(Gcd,b.get(i));
      }
      for(int i =Lcm;i<=Gcd;i+=Lcm){
        if(Gcd%i==0)
         count++;
      }
      return count;
    
    }
    

    }

    }
    

    }