Skip to content

Instantly share code, notes, and snippets.

@HeroicEric
Created June 8, 2014 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HeroicEric/312763510b868a10d444 to your computer and use it in GitHub Desktop.
Save HeroicEric/312763510b868a10d444 to your computer and use it in GitHub Desktop.
use std::io::println;
fn main() {
for num in range(1, 101) {
let answer =
if is_fifteen(num) {
~"FizzBuzz"
} else if is_three(num) {
~"Fizz"
} else if is_five(num) {
~"Buzz"
} else {
num.to_str()
};
println(answer)
}
}
fn is_three(num: int) -> bool {
num % 3 == 0
}
fn is_five(num: int) -> bool {
num % 5 == 0
}
fn is_fifteen(num: int) -> bool {
num % 15 == 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment