Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ch6ex1a;
- import java.util.Scanner;
- public class Ch6Ex1a
- {
- public static void main(String[] args)
- {
- Scanner sc=new Scanner(System.in);
- System.out.print("Enter a number: ");
- int num=sc.nextInt();
- boolean isPrime=true;
- for(int c=num-1;c>1;c--)if(num%c==0)isPrime=false;
- if(isPrime==true)System.out.println(num+" is prime.");
- else System.out.println(num+" is not prime.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement