Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Check_Prime_or_Not.java #732

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions Java/Check_Prime_or_Not.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import java.util.Scanner;

public class PrimeOrNot {
Expand All @@ -11,20 +12,20 @@ public static void main(String[] args) {
}

public static void primeOrNot(int num){
int count = 0;
int flag = 0;

if(num == 1){
System.out.println("1 is nether a prime number nor a composite number");
}
else
{
for(int i=1;i<=num;i++){
for(int i=2;i<num;i++){
if(num%i == 0){
count++;
flag=1;
}

}
if(count==2){
if(flag==0){
System.out.println("Prime Number");
}
else
Expand All @@ -34,6 +35,3 @@ public static void primeOrNot(int num){
}
}
}


//Created by Atul Jha