Skip to content
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
25 changes: 14 additions & 11 deletions week1/day2/PrimeNumber .java
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,40 @@ public static void main(String[] args) {


// Declare an int Input and assign a value 13

int value=13;


// Declare a boolean variable flag as false


boolean flag=false;

// Iterate from 2 to half of the input


for(int i=2;i<value/2;i++){

// Divide the input with each for loop variable and check the remainder

int remainder=value%i;


// Set the flag as true when there is no remainder

if(remainder==0){
flag=true;


// break the iterator

break;}}

// Check the flag (Provide a condition)



if(!flag){
System.out.println(value+" is a Prime Number");
}else
// Print 'Prime' when the condition matches

System.out.println(value+" is Not a Prime");


// Print 'Not a Prime' when the condition doesn't match

}

}
}