File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
src/main/java/com/thealgorithms/misc Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -8,9 +8,15 @@ private PalindromePrime() {
88 }
99
1010 public static boolean prime (int num ) {
11- if (num < 2 ) return false ; // Handle edge case for numbers < 2
12- if (num == 2 ) return true ; // 2 is prime
13- if (num % 2 == 0 ) return false ; // Even numbers > 2 are not prime
11+ if (num < 2 ) {
12+ return false ; // Handle edge case for numbers < 2
13+ }
14+ if (num == 2 ) {
15+ return true ; // 2 is prime
16+ }
17+ if (num % 2 == 0 ) {
18+ return false ; // Even numbers > 2 are not prime
19+ }
1420
1521 for (int divisor = 3 ; divisor <= Math .sqrt (num ); divisor += 2 ) {
1622 if (num % divisor == 0 ) {
@@ -31,7 +37,9 @@ public static int reverse(int n) {
3137
3238 public static List <Integer > generatePalindromePrimes (int n ) {
3339 List <Integer > palindromicPrimes = new ArrayList <>();
34- if (n <= 0 ) return palindromicPrimes ; // Handle case for 0 or negative input
40+ if (n <= 0 ) {
41+ return palindromicPrimes ; // Handle case for 0 or negative input
42+ }
3543
3644 palindromicPrimes .add (2 ); // 2 is the first palindromic prime
3745 int count = 1 ;
You can’t perform that action at this time.
0 commit comments