Activity: Fizz Buzz
Write a program that logs the numbers from 1 to 100. But for multiples of three log "Fizz" instead of that number, and for the multiples of five log "Buzz" instead of that number. For numbers which are multiples of both three and five log "FizzBuzz" instead. Hint: what operator can we use to detect if a number is divisible by another number? How did we do even/odd?
// Example output: for 1 - 16
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
Clean Code Challenge:
What if you want to log the numbers from 1 to 1000? How can we write our program in such a way that changing the range changes our code minimally? Hint: put it in a variable!
This is a question they ask in interviews! Loops, conditionals, and simple math are important in almost every program you will ever write.