# FizzBuzz with single semicolon

# Black Lives Matter

# FizzBuzz with single semicolon

Semicolon is a bit special in Rust. It only comes after statements, not expressions. that includes codeblock returns. This gave me a silly idea.

## How many semicolons needed to write a FizzBuzz program in Rust?

    fn main() {
        // for every number from 1 to 100
        for number in 1..100 {
            println!(
                "{}",
                {
                    // check if number is
                    if number % 15 == 0 {       // divisible by both 3 & 5
                        "fizzbuzz".to_string()      // if so return "fizzbuzz"
                    } else if number % 3 == 0 { // divisible by 3
                        "fizz".to_string()          // if so return "fizz"
                    } else if number % 5 == 0 { // divisible by 5
                        "buzz".to_string()          // if so return "buzz"
                    } else {                    // but if not
                        number.to_string()          // return number as String
                    }
                }
            );  // print returned value
        }
    }

# 1

There is also brute forcing method 🤦‍♂️️

Day 6 of #100DaysToOffload

## Comments

Toot on this thread to comment. This blog is a static site. Comments won't appear here.

## blogroll

- Kev Quirk
- Mike Stone
- Yarmo Mackenbach

## social

- atom feed
- rss feed
- Fostodon

Ali Murteza Yesil I'm a student, privacy advocate and SysAdmin wannabe. I was born in Turkey but I live abroad. Blogging Open Source Software Privacy