o3-2025-04-16· OpenAI
LMArena Human Preference 140K
java code for first 10 prime nos
- User
java code for first 10 prime nos
- Assistant
Here’s a compact Java program that prints the first 10 prime numbers:
javapublic class FirstTenPrimes { public static void main(String[] args) { int count = 0; // how many primes we’ve printed so far int num = 2; // number currently being tested while (count < 10) { if (isPrime(num)) { System.out.print(num + " "); count++; } num++; } } // Helper method to test primality private static boolean isPrime(int n) { if (n < 2) return false; if (n == 2) return true; if (n % 2 == 0) return false; // Check odd divisors up to √n for (int i = 3; i * i <= n; i += 2) { if (n % i == 0) return false; } return true; } }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.