Question

# Program to print all prime triplets in a given range

```				```
ENTER LOWER RANGE
1
ENTER UPPER RANGE
20
PRIME TRIPLET BETWEEN 1 and 20
(5,7,11)
(7,11,13)
(11,13,17)
(13,17,19)
(17,19,23)
```
```

# Share code with your friends

Code

```				```
import java.util.Scanner;
public class PrimeTripletInGivenRange
{
public static boolean isPrime(int num)
{

int j=0,count=0;
boolean flag=true;
if(num>1)
{
for(j=1;j<=num;j++)
{
/*Checking if number is divisible by j.*/
if(num%j==0)
{
count++;
}
}
if(count==2)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}

public static void main()
{
int lowerRange=0,upperRange=0,i=0;
Scanner sc=new Scanner(System.in);
System.out.println("ENTER LOWER RANGE");
lowerRange=sc.nextInt();
System.out.println("ENTER UPPER RANGE");
upperRange=sc.nextInt();
System.out.println("PRIME TRIPLET BETWEEN "+lowerRange+" and "+upperRange);

for(i=lowerRange;i<=upperRange;i++)
{
if(i>4)
{
if(isPrime(i)==true&&isPrime(i+2)==true && isPrime(i+6)==true)
{
System.out.println("("+i+","+(i+2)+","+(i+6)+")");
}
if(isPrime(i)==true&&isPrime(i+4)==true && isPrime(i+6)==true)
{
System.out.println("("+i+","+(i+4)+","+(i+6)+")");

}
}
}
}
}

```
```

Sale

50
Sale

150
Sale

200
Sale

50
Sale

50
Sale

50
Sale

50
Sale

50
Sale

50