Skip to content

Instantly share code, notes, and snippets.

@umcconnell
Created July 7, 2020 13:48
Show Gist options
  • Save umcconnell/15e5174c192d8aae61eacd79f5f2c4ec to your computer and use it in GitHub Desktop.
Save umcconnell/15e5174c192d8aae61eacd79f5f2c4ec to your computer and use it in GitHub Desktop.
Fizzbuzz in Rust
fn main() {
for x in 1..101 {
let mut out = String::new();
if x % 3 == 0 {
out += "fizz";
}
if x % 5 == 0 {
out += "buzz";
}
println!("{}", if out == "" {x.to_string()} else {out});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment