Check out example codes for "gcd". It will help you in understanding the concepts better.

Code Example 1

int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}

Learn ReactJs, React Native from akashmittal.com