-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLabNumbers.java
More file actions
35 lines (35 loc) · 804 Bytes
/
LabNumbers.java
File metadata and controls
35 lines (35 loc) · 804 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
29
30
31
32
33
34
35
/*A lab number is a number such that the square of any of its prime divisors is still one of its divisors.
Input: 8
Output: true (2 is a prime divisor of 8, and 2x2=4 is also a divisor of 8)
*/
import Xero.X;
import java.util.*;
public class LabNumbers
{
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
System.out.println("Enter the Number");
int num=in.nextInt();
int count=0;
for(int i=2;i<num;i++)
{
if(X.isPrime(i))
{
if(num%i==0)//Checking Prime divisor
{
int res=i*i;
if(num%res==0)//checking Square of the primes
{
System.out.println("Number is a Lab Number");
count++;break;
}
}
}
}
if(count==0)
{
System.out.println("Number is not a Lab Number");
}
}
}