You are viewing a single comment's thread. Return to all comments →
C++ using LCM & GCD
int LCM_count(int a,int b){ return (a*b)/__gcd(a,b); } int getTotalX(vector<int> a, vector<int> b) { int LCM=a[0]; for(int i=1;i<a.size();i++){ LCM=LCM_count(LCM,a[i]); } int GCD=b[0]; for(int i=1;i<b.size();i++){ GCD=__gcd(GCD,b[i]); } int count=0; for(int i=LCM;i<=GCD;i+=LCM){ if(GCD%i==0){ count++; } } return count; }
Seems like cookies are disabled on this browser, please enable them to open this website
Between Two Sets
You are viewing a single comment's thread. Return to all comments →
C++ using LCM & GCD