You are viewing a single comment's thread. Return to all comments →
C# solution
public static int getTotalX(List<int> a, List<int> b) { List<int> commonDivisors = new List<int>(); List<int> results = new List<int>(); int divisor = a.Max(); bool rightDigit = new bool(); while(divisor <= b.Min()) { rightDigit = true; foreach(int x in a) { if(divisor%x != 0){rightDigit = false;break;} } if(rightDigit) commonDivisors.Add(divisor); divisor++; } foreach(int commonDivisor in commonDivisors) { rightDigit = true; if(commonDivisor <= b.Min()) { foreach(int x in b) { if(x%commonDivisor != 0){rightDigit = false;break;} } } if(rightDigit) results.Add(commonDivisor); } return results.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# solution