• + 0 comments

    @rajat_yadav ye le.. tere wale se thoda easy hai

    static int gcd(int l,int e)
     {
         if(e==0)
         {
             return l;
         }
         else
         {
             return gcd(e,l%e);
         }
     }
     static int lcm(int[] e)
     {  
         int ans=1;
         for(int i:e)
         {
             ans=(ans*i)/gcd(ans,i);
         }
         return ans;
     }
    static int getTotalX(int[] a, int[] b) {
        /*
         * Write your code here.
         */
    
         int count=0;
         int g=b[0];
         int l=lcm(a);
         for(int i=1;i<b.length;i++)
         {
             g=gcd(g,b[i]);
         }
         int m=l;
         int i=1;
         while(m<=g)
         {
    
             m=l*i;
             if(g%m==0)
             {
                 count++;
             }
             i++;
    
         }
    
    return count;
    
    }