Current location - Recipe Complete Network - Complete cookbook - Write a Java program and output all the twin prime pairs within 100.
Write a Java program and output all the twin prime pairs within 100.
The code is as follows:

Public? Class? App? {

/***

? *? Judge? n? Whether it is a prime number or not.

? *? @param? n

? *? @ Return

? */

Static electricity Bull? isPrime(int? n)? {

For what? (int? Me? =? 2; ? Me? & lt? n; ? i++)? {

What if? (n? %? Me? ==? 0)? {

Return? Fake;

}

}

Return? True;

}

Public? Static electricity Invalid? main(String[]? args)? {

For what? (int? Me? =? 2; ? Me? & lt? 100; ? i++)? {

What if? (isPrime(i)? & amp& amp? IsPrime (me? +? 2))? {

System.out.println(i? +? ","? +? (me? +? 2));

}

}

}

} Running result: