Skip to content
This repository has been archived by the owner on Oct 23, 2018. It is now read-only.

Commit

Permalink
Add FizzBuzz rust program
Browse files Browse the repository at this point in the history
  • Loading branch information
eopb committed Oct 17, 2018
1 parent e2d29b5 commit 82f8660
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Rust/fizzbuzz.rs
@@ -0,0 +1,21 @@
// My take on fizzbuzz.
// Author: Ethan Brierley

fn main() {
let fizzbuzz = (1..).map(|val| {
if val % 3 == 0 {
if val % 5 == 0 {
"fizzbuzz".to_string()
} else {
"fizz".to_string()
}
} else if val % 5 == 0 {
"buzz".to_string()
} else {
val.to_string()
}
});
for x in fizzbuzz.take(25) {
println!("{}", x)
}
}

0 comments on commit 82f8660

Please sign in to comment.