Created
April 26, 2019 21:56
-
-
Save rust-play/6f41336b3985de7c45f0caa065f541ae to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
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
const FIZZABLE: u8 = 3; | |
const BUZZABLE: u8 = 5; | |
const FIZZBUZZABLE: u8 = FIZZABLE * BUZZABLE; | |
fn main() { | |
for i in 1..101 { | |
if i % FIZZBUZZABLE == 0 { | |
print!("FizzBuzz"); | |
} | |
else if i % BUZZABLE == 0 { | |
print!("Buzz"); | |
} | |
else if i % FIZZABLE == 0 { | |
print!("Fizz"); | |
} | |
else { | |
print!("{}", i); | |
} | |
if i < 100 { | |
print!(", "); | |
} | |
else { | |
print!("!"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment