Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class VerificarSeONumeroéPrimoMethodosEstaticosRetorno {
  3.  
  4. public static void main(String[] args) {
  5. Scanner leitura=new Scanner(System.in);
  6. int numero=leitura.nextInt();
  7. if(ÉPrimo(numero)) {
  8. System.out.println("é primo");
  9. }
  10. else
  11. {
  12. System.out.println("não é primo");
  13. }
  14. leitura.close();
  15. }
  16.  
  17. public static boolean ÉPrimo(int numero) {
  18.  
  19. for (int j = 2; j < numero; j++) {
  20. if (numero % j == 0)
  21. return false;
  22. }
  23. return true;
  24. }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement