Merge pull request #1 from MehraDevesh2022/MehraDevesh2022-patch-1

added new algo. into : algorithms/java/Maths dir..
pull/900/head
Devesh Mehara 2022-10-03 10:05:22 +05:30 committed by GitHub
commit 0c2a362b1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 0 deletions

View File

@ -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;
}
}