-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprime.java
More file actions
28 lines (28 loc) · 827 Bytes
/
Copy pathprime.java
File metadata and controls
28 lines (28 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**********************************************************************
* File :prime.java
* Description :To check whether a given number is prime or not
* Author :Shraya S Santhosh
* Version :1.0
* Date :31/10/2023
*******************************************************************/
package newproj;
import java.util.Scanner;
public class prime {
public static void main(String[]args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter number ");
int number=sc.nextInt();
int flag=0;
for(int i=2;i<number;i++) {
if(number%i==0) {
flag++;
}
}
if (flag==0) {
System.out.println(number+" is prime");
}
else {
System.out.println(number+" is not prime");
}
}
}