Generation

generate functionTue, 21 Feb 2023

display prime numbers that are also square numbers

while (i <= 100) { j = 2; while (j <= (int) Math.sqrt(i)) { if (i % j == 0) break; // else j++; } if (j > (int) Math.sqrt(i)) { // i is prime if (Math.sqrt(i) % 1 == 0) { // i is square System.out.println(i); } } i++; }

Questions about programming?Chat with your personal AI assistant