Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package exercicios_for;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int x = 0;
- while(true) {
- System.out.print("Digite um número de 0 a 100: ");
- x = sc.nextInt();
- if(x >= 0 && x <= 100)
- {
- System.out.printf("Os números primos de 0 a %d são:\n", x);
- for (int i=0 ; i<=x ; i++) {
- if (i % 2 !=0)
- System.out.println(i);
- }
- System.exit(0);
- }
- else
- {
- System.out.println("Número fora do intervalo.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement