
find the 127 twin pair in java

class TwinPrimes{
public static void main(String args[]) {
int i = 2;
int count = 0;
int j = 0;
int LastPrime = 1;
System.out.println("Twin Primes are:");
while(count < 107) {
for(j = 2; j < i; j++) {
if (i % j == 0) {
break;
}
}
if(i == j){
if ((i - LastPrime) == 2){
System.out.println("("+(i-2)+","+i+")");
count++;
}
LastPrime = i;
}
i++;
}
System.out.println("fghgf=("+(i-2)+","+i+")");
}
}

class TwinPrimes{
public static void main(String args[]) {
int i = 2;
int count = 0;
int j = 0;
int LastPrime = 1;
System.out.println("Twin Primes are:");
while(count < 107) {
for(j = 2; j < i; j++) {
if (i % j == 0) {
break;
}
}
if(i == j){
if ((i - LastPrime) == 2){
System.out.println("("+(i-2)+","+i+")");
count++;
}
LastPrime = i;
}
i++;
}
System.out.println("127 th prime =("+(i-3)+","+(i-1)+")");
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.