Last active
September 25, 2015 15:16
-
-
Save dheshanm/61c818d4108fd73548b3 to your computer and use it in GitHub Desktop.
Uses Method()
This file contains hidden or 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
| package starting.java.tutorials; | |
| import java.util.Scanner; | |
| /** | |
| * Created by dheshan on 9/25/2015. | |
| */ | |
| public class TEST { | |
| public static int Prime(int number){ | |
| int i=0,z=0; | |
| for(int n=2;n<number;n++){ | |
| if(number%n==0){ | |
| //System.out.println("The number is not a Prime Number"); | |
| i=1; | |
| z=0; | |
| break; | |
| } | |
| } | |
| if(i==0){ | |
| //System.out.println("The number is a Prime Number"); | |
| z=1; | |
| } | |
| return (z); | |
| } | |
| public static void main(String Args[]){ | |
| Scanner in=new Scanner(System.in); | |
| int num; | |
| System.out.print("Enter a number :"); | |
| num=in.nextInt(); | |
| if(Prime(num)==1){ | |
| System.out.println("The number is a Prime Number"); | |
| } | |
| if(Prime(num)==0){ | |
| System.out.println("The number is not a Prime Number"); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment