Created
September 20, 2023 01:25
-
-
Save jchild3rs/a3e6b8eb58df0f8fa68a1201860e6cab to your computer and use it in GitHub Desktop.
rust fizz buzz
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
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