grok-3-mini-beta· xAI
LMArena Human Preference 140K
write fizz buzz in rust
- User
write fizz buzz in rust
- Assistant
Below is a simple implementation of the Fizz Buzz program in Rust. This program prints the numbers from 1 to 100, but replaces them with "Fizz" if the number is divisible by 3, "Buzz" if it's divisible by 5, and "FizzBuzz" if it's divisible by both (i.e., 15).
fn main() { for i in 1..=100 { // Loop from 1 to 100 inclusive if i % 15 == 0 { // Check if divisible by 15 (both 3 and 5) println!("FizzBuzz"); } else if i % 3 == 0 { // Check if divisible by 3 println!("Fizz"); } else if i % 5 == 0 { // Check if divisible by 5 println!("Buzz"); } else { println!("{}", i); // Otherwise, print the number } } }How to Run This Code:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.