Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 15, 2021 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/58e7cea4e306bf474fdf37f17083d93c to your computer and use it in GitHub Desktop.
Save parzibyte/58e7cea4e306bf474fdf37f17083d93c to your computer and use it in GitHub Desktop.
public static void productoDePares() {
Scanner sc = new Scanner(System.in);
int numero = 1;
int producto = 1;
while (numero != 0) {
System.out.println("Escribe un número (escribe 0 si quieres finalizar)");
numero = sc.nextInt();
if (numero != 0 && esPar(numero)) {
producto *= numero;
}
}
System.out.println("Producto de los números pares: " + producto);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment