first commit

This commit is contained in:
2021-04-14 16:00:09 +05:30
commit 430dfcee8b
16 changed files with 574 additions and 0 deletions

26
PrimeOrNot.java Normal file
View File

@@ -0,0 +1,26 @@
// Program to find out whether the number is Prime or Not (Dynamic Method);
import java.util.Scanner;
public class PrimeOrNot {
public static void main(String[] args) {
int num, i = 2;
System.out.println("Enter the number: ");
Scanner s = new Scanner(System.in);
num = s.nextInt();
boolean flag = false;
while (i <= num / 2) {
if (num % i == 0) {
flag = true;
break;
}
++i;
}
if (!flag) {
System.out.println(num + " is a prime number");
}
else {
System.out.println(num + " is not a prime number");
}
}
}