Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created April 26, 2019 21:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/6f41336b3985de7c45f0caa065f541ae to your computer and use it in GitHub Desktop.
Save rust-play/6f41336b3985de7c45f0caa065f541ae to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
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