# beanz Magazine

## FizzBuzz

CollegeDegrees360 on Flickr

It’s not as simple as it seems. Can you solve this classic programming problem?

Your challenge is to print out a list of numbers from 1 to 100. Every number divisible by 3 must be replaced by the word ‘fizz’, and every number divisible by 5 is replaced by ‘buzz’. If the number is divisible by both 3 and 5, then replace it with ‘fizzbuzz’.

It’s a simple problem with many solutions, from the quick and easy to the complex and elegant. In computer geek circles, ‘FizzBuzz’ is a classic puzzle that pops up time and time again. Companies even ask it to candidates during coding interviews!

Take a moment and think about how you’d approach the code. What hurdles could you hit? What coding structures can you pull out of your arsenal?

### A SIMPLE SOLUTION

The piece of code that makes things simple is the modulus operator, which you write as “%” and say out loud as “mod”. It’s a mathematical operator, like +, -, or *, and it tells us how much is leftover after a division.

Remember how we did divisions before learning about decimal numbers? So if:

15 / 6 == 2 (with a of remainder 3)
THEN
15 % 6 == 3

### Also In The February 2019 Issue

The craft world and the tech world collide in this fun, hands-on activity.

A simple coding activity to create triangles in all shapes and sizes.

Five ideas to create that extra special gift for Valentine’s Day.

For twenty three years, since 1996, cars have used computers to control different parts of the car.

Celebrate Lunar New Year with your own custom-built lantern, complete with LEDs and micro:bit!

Synchronizing games with players from all around the world is no easy task.

A simple thought experiment sheds light on the dangers of AI. Can we stop the earth being buried in paperclips?

What do students really learn from robotics class? And how can we make it better?

Create a dynamic optical illusion in SketchUp.

Learn how rockets may soon be able to refuel in 0G. Next stop: Mars!

‘Files’ may be easy concepts for humans, but not for computers. What’s going on inside your operating system?

Two ways to play Minecraft with an overarching storyline. Experience the game like never before!

Helping kids fall in love with coding through Minecraft mods and Raspberry Pis.

Learn why this powerful, 40-year old language is still popular today.

A better, smoother way to direct your theatrical masterpiece.

Explore the past of cellular phone technology, and take a peek into its future.

How hackers can steal the messages you send over the internet, and how to tell if your communications are secure.

Add multimedia & more to your fantasy computer game to make it cooler than ever.

It’s not as simple as it seems. Can you solve this classic programming problem?

Ever wondered what happens when you connect to a website? Time to dive into the secrets of networking!

Links from the bottom of all the February 2019 articles, collected in one place for you to print, share, or bookmark.

Interesting stories about science and technology for February 2019.