r/shittyprogramming • • Oct 06 '21
FizzBuzz compact version
fn main(){for num in 1..101{if num%5==0&&num%3==0{println!("FizzBuzz")}else if num%5==0{println!("Buzz")}else if num%3==0{println!("Fizz")}else{println!("{}",num)}}}
48
Upvotes
View all comments
Show parent comment
13
u/BobGeneric Oct 06 '21
Next skip the if's and else's... that's luxury and unnecessary. Real programmers only use ternaries. Better yet if you negate the condition, and avoid the use of parentesis.