You are looking for the greatest common divisor of the numbers, and then divide the numbers by that GCD. There is a built-in method for this in the
System.Numerics.BigInteger
class (you'll need to add a reference to System.Numerics before you can use it). Add this on the top of your code file, after adding a reference to System.Numerics:
using System.Numerics;
And then, use this code:
string input = "100/30";
string[] numbers = input.Split('/');
int numerator;
int denominator;
if (numbers.Length == 2 && int.TryParse(numbers[0], out numerator) && int.TryParse(numbers[1], out denominator))
{
BigInteger gcd = BigInteger.GreatestCommonDivisor(new BigInteger(numerator), new BigInteger(denominator));
int gcdInt = (int)gcd;
int newNumerator = numerator / gcdInt;
int newDenominator = denominator / gcdInt;
string result = String.Concat(newNumerator, "/", newDenominator);
}
else
{
}