o4-mini-2025-04-16· OpenAI
LMArena Human Preference 140K
wrtie fizz buzz in rust
- User
wrtie fizz buzz in rust
- Assistant
Here’s a simple FizzBuzz implementation in Rust (printing 1 through 100). Copy this into a
main.rsand run withcargo runorrustc main.rs && ./main.fn main() { for n in 1..=100 { match (n % 3, n % 5) { (0, 0) => println!("FizzBuzz"), // divisible by both 3 and 5 (0, _) => println!("Fizz"), // divisible by 3 (_, 0) => println!("Buzz"), // divisible by 5 _ => println!("{}", n), // neither: print the number } } }Explanation:
1..=100is an inclusive range from 1 to 100.- The
matchchecks the remainders of dividing by 3 and 5:(0, 0)means divisible by both → prints “FizzBuzz”(0, _)means divisible by 3 only → prints “Fizz”(_, 0)means divisible by 5 only → prints “Buzz”_catches all other cases → prints the number itself.
If you’d like to customize the range or output style (e.g. return a
Vec<String>instead of printing), just let me know! 🎉
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.