Skip to content

Instantly share code, notes, and snippets.

@bradclawsie
Created October 13, 2012 07:35
Show Gist options
  • Save bradclawsie/3883686 to your computer and use it in GitHub Desktop.
Save bradclawsie/3883686 to your computer and use it in GitHub Desktop.
fizzbuzz.rs
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