diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..53eaa21 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/rust/fizzbuzz/src/main.rs b/rust/fizzbuzz/src/main.rs new file mode 100644 index 0000000..51a6eba --- /dev/null +++ b/rust/fizzbuzz/src/main.rs @@ -0,0 +1,17 @@ +fn fizzbuzz(x: i32) -> String { + if x%15 == 0 { + return "FizzBuzz".to_string(); + } else if x%5 == 0 { + return "Buzz".to_string(); + } if x%3 == 0 { + return "Fizz".to_string(); + } else { + return x.to_string(); + } +} + +fn main() { + for i in 1..50 { + println!("{} ", fizzbuzz(i)); + } +}