This is just a practice challenge on HackerEarth, as followed: https://www.hackerearth.com/challenge/test/programming-practice-challenge/algorithm/c6f4c9b405004de4937dd5e641b1b2f8/The problem is straightforward. Before I came up with this version, I thought to adopt the Euclidean algorithm for finding the common factor, but clearly its solution wouldn't be right for the case of something like 4 8 So, this is what I've got so far: #include <iostream>using namespace std;int main(){    int a, b;     cin >> a >> b;     //find the common factor of a & b, initially inclusive of 1     int r;     int fac = 1;     int min = a < b ? a : b;     for (int i = 2; i <= min; i++){        if (a % i == 0 && b % i == 0){            fac++;        }    }    cout << fac << endl;     return 0;}I thought the algorithm is correct for most of cases I've come up with. But I got partially accept for the final result because maybe these are still some hidden tests this code doesn't produce the exact results. Can someone help me figure this out? 
Common factor of two numbers
c++;algorithm