Created
July 7, 2020 13:48
-
-
Save umcconnell/15e5174c192d8aae61eacd79f5f2c4ec to your computer and use it in GitHub Desktop.
Fizzbuzz in Rust
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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