Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class punto4 {
- public static void main(String[] args) {
- Scanner num= new Scanner (System.in);
- int x,contador=0;
- System.out.println("Ingrese un numero positivo");
- x=num.nextInt();
- if (x>0) {
- for(int i=1;i<=x;i++) {
- if(x%i==0) {
- contador++;
- }
- }
- if(contador==2) {
- System.out.println("es primo");
- }
- else {
- System.out.println("no es primo");
- }
- }
- else {
- System.out.println("el numero ingresado no es positivo");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment