Created
June 8, 2014 21:22
-
-
Save HeroicEric/312763510b868a10d444 to your computer and use it in GitHub Desktop.
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
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