#include <iostream> using namespace std; int mcd(int n1,int n2) { if(n1%n2==0) return n2; else return mcd(n2,n1%n2); } int main() { int n1; int n2; cout << "Ingrese n1: "; cin >> n1; cout << "Ingrese n2: "; cin >> n2; cout << "MCD: " << mcd(n1, n2); }
Copiar, pegar y ejecutar este script en http://cpp.sh/
No hay comentarios:
Publicar un comentario