-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumerosPares.java
More file actions
32 lines (27 loc) · 1018 Bytes
/
NumerosPares.java
File metadata and controls
32 lines (27 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**********************************************************************************************
*
*DESAFIO: Exibição de Sequencia de Números Pares até n
*
*Crie um programa que leia um número e mostre os números pares até esse número, inclusive
* ele mesmo.
*
*Entrada: Você receberá 1 valor inteiro N, onde N > 0.
*Saída: Exiba todos os números pares até o valor de entrada, sendo um em cada linha.
*
* Exemplo: entrada = 6 -> exiba 2 4 6
**********************************************************************************************/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class ExibicaoNumerosPares {
public static void main(String[] args) throws IOException {
String entrada;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
entrada = br.readLine();
for (int i = 2; i <= Integer.parseInt(entrada); i++) {
if (i % 2 == 0) {
System.out.println(i);
}
}
}
}