import java.util.Scanner;
class Recursividad04 {
public static int mcd(int a, int b) {
if (a % b == 0) {
return b;
} else {
return mcd(b, a % b);
}
}
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int x, y;
do {
System.out.print("Ingrese primer numero :");
x = in.nextInt();
} while (x <= 0);
do {
System.out.print("Ingrese segundo numero :");
y = in.nextInt();
} while (y <= 0);
System.out.println("El mcd de " + x + " y " + y + " es : " + mcd(x, y));
}
}
0 comentarios:
Publicar un comentario