Last active
August 29, 2015 14:20
-
-
Save mikestratton/71f69a04d71acfb862f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
class primeNumber { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
System.out.print("Enter your input number:"); | |
int n = scanner.nextInt(); | |
int j = 2; | |
int result = 0; | |
while (j <= n / 2) | |
{ | |
if (n % j == 0) | |
{ | |
result = 1; | |
} | |
j++; | |
} | |
if (result == 1) | |
{ | |
System.out.println("Not a prime number"); | |
} | |
else | |
{ | |
System.out.println("Input number is a prime number"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment