Prog
Prog
Prog
class FibonacciCalculator {
public int[] generateSeries(int n) {
int[] series = new int[n];
if (n >= 1) {
series[0] = 1;
}
if (n >= 2) {
series[1] = 1;
}
for (int i = 2; i < n; i++) {
series[i] = series[i - 1] + series[i - 2];
}
return series;
}
}
Ejercicio N° 3
import java.util.Scanner;
System.out.println("El mínimo común múltiplo de " + num1 + " y " + num2 + "
es: " + lcm);
scanner.close();
}
public static int calcularGCD(int a, int b) {
while (b != 0) {
int temp = b;
b = a % b;
a = temp;
}
return a;
}
public static int calcularLCM(int a, int b) {
return (a * b) / calcularGCD(a, b);
}
}
Ejercicio N° 4
import java.util.Scanner;
scanner.close();
}
scanner.close();
}