gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
rewrite this python script in bash
- User
rewrite this python script in bash
- Assistant
#!/bin/bash # Function to check if a number is prime is_prime() { local n=$1 if [ $n -lt 2 ]; then return 1 fi for ((i=2; i*i<=n; i++)); do if ((n%i == 0)); then return 1 fi done return 0 } # Get user input read -p "Enter a number: " num # Check if the input number is prime is_prime $num if [ $? -eq 0 ]; then echo "$num is a prime number." else echo "$num is not a prime number." fiThe given Python script is a script to check if a number is prime. The rewritten script in bash performs the same functionality.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.