code fizzbuzz in efficient way with the shortest lines, in rust.
- User
code fizzbuzz in efficient way with the shortest lines, in rust.
Assistant
Here is an implementation of FizzBuzz in Rust that uses the shortest lines:
codefn main() { for i in 1..=100 { if i % 3 == 0 && i % 5 == 0 { println!("FizzBuzz"); } else if i % 3 == 0 { println!("Fizz"); } else if i % 5 == 0 { println!("Buzz"); } else { println!("{}", i); } } }This implementation uses a
forloop to iterate over the numbers 1 to 100. Inside the loop, it usesifstatements to check the conditions for each number and print the appropriate string.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.