Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class NumPrimo {
- public static void main(String args[]){
- Scanner leia = new Scanner(System.in);
- System.out.printf("Entre com o numero: ");
- int num = leia.nextInt();
- int cont = 0;
- for(int i=1; i<=num; i++){
- if (num%i==0){
- cont++;
- }
- }
- String primo = (cont==2) ? "\neh primo\n" : "\nnao eh primo\n";
- System.out.print(primo);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement