SHARE
TWEET

Ch6Ex1a

KeeganT Feb 21st, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package ch6ex1a;
  2. import java.util.Scanner;
  3.  
  4. public class Ch6Ex1a
  5. {
  6.     public static void main(String[] args)
  7.     {
  8.         Scanner sc=new Scanner(System.in);
  9.         System.out.print("Enter a number: ");
  10.         int num=sc.nextInt();
  11.         boolean isPrime=true;
  12.         for(int c=num-1;c>1;c--)if(num%c==0)isPrime=false;
  13.         if(isPrime==true)System.out.println(num+" is prime.");
  14.         else System.out.println(num+" is not prime.");
  15.     }
  16. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top