Generate the first n prime numbers and time complexity.
Anonymous
private static void generatePrime(int n) { for(int i = 2; i < n; i++) { boolean status = true; for(int j = 2; j <= Math.sqrt(i); j++) { if(i%j == 0) { status = false; } } if(status) System.out.print(i+", "); } }
Check out your Company Bowl for anonymous work chats.