Skip to content

Instantly share code, notes, and snippets.

@jchild3rs
Created September 20, 2023 01:25
Show Gist options
  • Save jchild3rs/a3e6b8eb58df0f8fa68a1201860e6cab to your computer and use it in GitHub Desktop.
Save jchild3rs/a3e6b8eb58df0f8fa68a1201860e6cab to your computer and use it in GitHub Desktop.
rust fizz buzz
fn main() {
fizzbuzz(15);
}
fn fizzbuzz(n: i32) {
for i in 1..n {
if i % 3 == 0 && i % 5 == 0 {
println!("FizzBuzz");
} else if i % 3 == 0 {
println!("Fizz");
} else if i % 5 == 0 {
println!("Buzz");
} else {
println!("{}", i);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment