Check out example codes for "how to calculate ratio in c#". It will help you in understanding the concepts better.

Code Example 1

public string GetRatio(int a, int b)
{
	var gcd = GCD(a, b);
  	return string.Format("{0}:{1}", a / gcd, b / gcd);
}
public int GCD(int a, int b)
{
	return b == 0 ? Math.Abs(a) : GCD(b, a % b);
}

// Tomas Pajonk's Answer:
public int GCD_(int a, int b)
{
	while (a != 0 && b != 0)
    {
    	if (a > b)
        {
        	a %= b;
        }
      	else
        {
        	b %= a;
        }
    }
  	if (a == 0)
    {
    	return b;
    }
  	else
    {
    	return a;
    }
}
public string GetRatio_(int a, int b)
{
	var gcd_ = GCD_(a, b);
  	return string.Format("{0}:{1}", a / gcd_, b / gcd_);
}

Learn ReactJs, React Native from akashmittal.com