Merge pull request #1 from MehraDevesh2022/MehraDevesh2022-patch-1
added new algo. into : algorithms/java/Maths dir..pull/900/head
commit
0c2a362b1f
|
@ -0,0 +1,21 @@
|
|||
import java.util.*;
|
||||
|
||||
public class Main{
|
||||
public static void main(String[] args) {
|
||||
Scanner scn = new Scanner(System.in);
|
||||
int num = scn.nextInt();
|
||||
boolean ans = isPrime(num);
|
||||
if(ans =! true) System.out.println("not prime");
|
||||
else System.out.println("prime");
|
||||
}
|
||||
|
||||
|
||||
public static boolean isPrime(int num){
|
||||
for(int i=2; i*i<num; i++){
|
||||
if(num %2 ==0){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue