Ejercicio 4 eficiente
This commit is contained in:
1 parent
296ce2f729
commit
8ee32e659d
1 file changed
+1
-3
@@ -6,9 +6,8 @@ public class EstructuraRepetitiva4 {
|
|||||||
System.out.println("Introduce un número entero: ");
|
System.out.println("Introduce un número entero: ");
|
||||||
int n = sc.nextInt();
|
int n = sc.nextInt();
|
||||||
|
|
||||||
for (int i = 3; i <= n; i++) {
|
for (int i = 3; i <= n; i+=3) {
|
||||||
boolean primero = true; // Para poner la , bien
|
boolean primero = true; // Para poner la , bien
|
||||||
if (i % 3 == 0) {
|
|
||||||
System.out.printf("Múltiplo=%d divisores del %d: (", i, i);
|
System.out.printf("Múltiplo=%d divisores del %d: (", i, i);
|
||||||
for (int j = 1; j <= i; j++) {
|
for (int j = 1; j <= i; j++) {
|
||||||
if (i % j == 0) {
|
if (i % j == 0) {
|
||||||
@@ -19,7 +18,6 @@ public class EstructuraRepetitiva4 {
|
|||||||
}
|
}
|
||||||
System.out.print(")\n");
|
System.out.print(")\n");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
sc.close();
|
sc.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user