Ejercicios estructura repetitiva
This commit is contained in:
1 parent
70b99a0a23
commit
99ade1ddb3
6 files changed
+113
-16
No files matched your search
@@ -1,3 +1,25 @@
|
||||
void main() {
|
||||
$END$
|
||||
}
|
||||
import java.util.Scanner;
|
||||
|
||||
public class EstructuraRepetitiva4 {
|
||||
static void main(String[] args) {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
System.out.println("Introduce un número entero: ");
|
||||
int n = sc.nextInt();
|
||||
|
||||
for (int i = 3; i <= n; i++) {
|
||||
boolean primero = true; // Para poner la , bien
|
||||
if (i % 3 == 0) {
|
||||
System.out.printf("Múltiplo=%d divisores del %d: (", i, i);
|
||||
for (int j = 1; j <= i; j++) {
|
||||
if (i % j == 0) {
|
||||
if (!primero) System.out.print(",");
|
||||
System.out.printf("%d", j);
|
||||
primero = false;
|
||||
}
|
||||
}
|
||||
System.out.print(")\n");
|
||||
}
|
||||
}
|
||||
sc.close();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user