52 lines
704 B
C
52 lines
704 B
C
#include <stdio.h>
|
|
|
|
// Declaración de funciones
|
|
int rec(int num1, int num2);
|
|
int rec2(int num1, int num2);
|
|
|
|
// Función recursiva rec
|
|
int rec(int num1, int num2)
|
|
{
|
|
int n;
|
|
|
|
if (num2 == 0)
|
|
{
|
|
n = num1;
|
|
}
|
|
else
|
|
{
|
|
n = rec(num2, num1 % num2);
|
|
}
|
|
|
|
return n;
|
|
}
|
|
|
|
// Función rec2 que utiliza rec
|
|
int rec2(int num1, int num2)
|
|
{
|
|
int n;
|
|
|
|
n = rec(num1, num2);
|
|
|
|
return num1 * num2 / n;
|
|
}
|
|
|
|
// Función principal (main)
|
|
int main()
|
|
{
|
|
int num1, num2;
|
|
int result;
|
|
|
|
printf("Input num1: ");
|
|
scanf("%d", &num1);
|
|
|
|
printf("Input num2: ");
|
|
scanf("%d", &num2);
|
|
|
|
result = rec2(num1, num2);
|
|
|
|
printf("Result: %d\n", result);
|
|
|
|
return 0;
|
|
}
|