import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String n;
do {
try {
System.out.println("Escribe un número: ");
n = br.readLine();
if (Integer.parseInt(n) > 0) {
int i = 1;
while (i <= Integer.parseInt(n)) {
System.out.println("Divisores de " + i);
int j = 1;
while (j <= i) {
if (i % j == 0) {
System.out.println(j);
}
j = j + 1;
}
i = i + 1;
}
} else {
n = "";
}
} catch (NumberFormatException | IOException e) {
n = "";
}
} while (n.isEmpty());
}
}
[/aux_code]
Divisores de un número
con
No hay comentarios
[aux_code language=»javascript» theme=»tomorrow» title=»Divisores de un número» extra_classes=»»]