Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@SuperJMN
Created July 30, 2016 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SuperJMN/82503d1c5d313087aa2caaf93d199a9d to your computer and use it in GitHub Desktop.
Save SuperJMN/82503d1c5d313087aa2caaf93d199a9d to your computer and use it in GitHub Desktop.
namespace Mcd
{
class MainClass
{
public static void Main (string[] args)
{
Console.WriteLine (Calculo.Mcd(75, 100));
}
}
public static class Calculo
{
public static int Mcd(int a, int b)
{
var mayor = Math.Max (a, b);
var menor = Math.Min (a, b);
return McdOrdenado (mayor, menor);
}
private static int McdOrdenado(int mayor, int menor)
{
var resto = mayor % menor;
if (resto == 0)
return menor;
else
return Mcd (menor, resto);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment