Grok 4.1 Fast· xai
Frontier Reasoning Traces
Write a Python function to check if a number is a prime.
- User
Write a Python function to check if a number is a prime.
- Assistant
import math def is_prime(n): """ Check if a number is prime. Args: n (int): The number to check. Returns: bool: True if n is prime, False otherwise. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return TrueExample usage:
print(is_prime(2)) # True print(is_prime(17)) # True print(is_prime(4)) # False print(is_prime(1)) # False print(is_prime(7919)) # True
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.