Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class VerificarSeONumeroéPrimoMethodosEstaticosRetorno {
- public static void main(String[] args) {
- Scanner leitura=new Scanner(System.in);
- int numero=leitura.nextInt();
- if(ÉPrimo(numero)) {
- System.out.println("é primo");
- }
- else
- {
- System.out.println("não é primo");
- }
- leitura.close();
- }
- public static boolean ÉPrimo(int numero) {
- for (int j = 2; j < numero; j++) {
- if (numero % j == 0)
- return false;
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement