### [2017-04-12] Challenge #310 [Intermediate] Simplifying square roots

i'm still pretty new to programming in c# but I gave it a shot, probably over complicated things: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace Practice_4_12_17 { class Program { static int getVar(out int a, out int b, out int c, out int d) { /* Gets the values to be used / Console.Write("a: "); a = Convert.ToInt32(Console.ReadLine()); Console.Write("b: "); b = Convert.ToInt32(Console.ReadLine()); Console.Write("c: "); c = Convert.ToInt32(Console.ReadLine()); Console.Write("d: "); d = Convert.ToInt32(Console.ReadLine()); return a + b + c + d; } static void Main(string[] args) { Console.WriteLine("Let's simplify an equation:"); Console.WriteLine("Let's start off with an equation in the form of (asqrt(b))/(csqrt(d))"); Console.WriteLine("And let's elimnate the radical in the denominator, thus eliminating the 'd'"); Console.WriteLine("And putting the equation in the form of (asqrt(b))/c"); Console.WriteLine("Naturally, this means that the values for a, b, and c will have to change"); Console.WriteLine("\nPlease enter the values for a, b, c, and d: \n");

``````        int a, b, c, d;
//Go to method to obtain values
getVar(out a, out b, out c, out d);

//Verify correct values have been input
Question:
Console.WriteLine("\n \nSo you want to simplify ({0}*sqrt({1}))/({2}*sqrt({3})) (y/n)? \n", a, b, c, d);
string ans;
switch (ans)
{
case "y":
break;
case "n":
Console.WriteLine();
getVar(out a, out b, out c, out d);
goto Question;
default:
goto Question;

}

//define 2nd instance of variables
int a2 = a;
int b2;
int c2 = c * d;

//start doing the simplifying

//find new b (and maybe a)
int power = 0;

int evenSqrt = 0;
if (quickCheck % 1 == 0)
{
evenSqrt = 1;
goto A_and_C_Reduction;
}

int reduceIt;
for(int p = 2; p <= factor; p++)
{
int p2 = p * p;
switch (reduceIt)
{
case 0:
power += p;
default:
break;
}
}
int power2 = power * power;
if (power > 0)
{
a2 *= power;
}

//find new a and c
A_and_C_Reduction:

int reduction = (c/2);

Bring_It_Down:

for(int x = 2; x <= reduction; x++)
{
if((a2%x == 0) && (c2%x == 0))
{
a2 /= x;
c2 /= x;
goto Bring_It_Down;
}
}

if (c2 != 1)
{
switch (evenSqrt)
{
case 1:
int b3 = Convert.ToInt32(Math.Sqrt(b2));
int a3 = a2 * b3;
Console.WriteLine("\n'b' and 'd' have been elimnated");
Console.WriteLine("a now equals {0} and c now equals {1}\n", a3, c2);
Console.WriteLine("({0}/{1})", a3, c2);
int divisible = a3 % c2;
if (divisible == 0)
{
int a4 = a3 / c2;
Console.WriteLine("'c' was a factor of 'a', as a result the entire number is:");
Console.WriteLine(a4);
}
break;

default:
Console.WriteLine("\n'd' has been elimnated");
Console.WriteLine("a now equals {0}, b now equals {1}, and c now equals {2}\n", a2, b2, c2);
Console.WriteLine("({0}*sqr({1})/{2}", a2, b2, c2);
break;
}
}
else
{
Console.WriteLine("\n'c' and'd' have been elimnated");
Console.WriteLine("('c' is eliminated because it is giving us a denominator of 1");
Console.WriteLine("a now equals {0}, b now equals {1}, and c now equals {2}", a2, b2, c2);
if (evenSqrt == 1)
{
int a3 = a2 * b2;
Console.WriteLine("\n'b' has also been elimnated seeing as it equals '1' now");
Console.WriteLine("the number left over (the entire fraction) is {0}", a3);
}
else
{