Created
October 13, 2012 07:35
-
-
Save bradclawsie/3883686 to your computer and use it in GitHub Desktop.
fizzbuzz.rs
This file contains hidden or 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
extern mod std; | |
fn main() { | |
let mut i = 1; | |
while i <= 100 { | |
let mod3 = ((i % 3) == 0); | |
let mod5 = ((i % 5) == 0); | |
if ! (mod3 || mod5) { | |
io::println(fmt!("%d",i)); | |
} else { | |
let mut s = ~""; | |
if mod3 { s += "Fizz"; } | |
if mod5 { s += "Buzz"; } | |
io::println(fmt!("%s",s)); | |
} | |
i = i + 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment