How to do functions, for loops and conditionals — using FizzBuzz. In this post, we’ll create a function to solve the overly popular FizzBuzz programming challenge.
In this post, we’ll create a function to solve the overly popular FizzBuzz programming challenge.
By the end of this article, you will know:
This post is meant for beginner programmers or for those who never heard of Julia before. Don’t expect to do [earth-shattering massively parallel scientific workloads_](https://www.nextplatform.com/2017/11/28/julia-language-delivers-petascale-hpc-performance/) after reading this. Consider this as your humble beginnings in the awesome world of Julia._
If you’ve never heard of it, FizzBuzz is a simple counting game, aiming to teach kids multiplicative tables. Participants gather around in a circle and someone starts counting from 1. The next person continues with 2 and so on, going around the circle. The trick is that if the number is divisible by 3, then instead of saying the number, the player should say Fizz. If the number is divisible by 5, then they should say Buzz. And if the number is divisible by both 3 and 5 then they should say FizzBuzz.
I guess you could play this game with any other 2 numbers, but 3 and 5 are the most popular choices.
This simple game has been translated to a programming challenge to torment beginner programmers. It also gives us a good chance to practice for loops and if statements in Julia. Let’s see how we can create a function that prints the solution for the first n numbers.
I’ve previously solved FizzBuzz in BigQuery, so if you’re interested in knowing how you can solve this using a PB scale data warehouse, check out my [article here_](https://towardsdatascience.com/fizzbuzz-in-bigquery-e0c4fbc1d195)._
Instead of just running through the problem, let’s go step by step and see how we can tackle this problem.
I find it quite important to have a** clear idea of what the function should achieve**. In our case, we want to print the first n
numbers, but replacing numbers divisible by 3 with Fizz, 5 by Buzz and those that are divisible by both 3 and 5 (or 15 for you math geniuses out there) by FizzBuzz.
programming-languages programming loop julialang beginners-guide
Guide to Python Programming Language
SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.
In this video, you will know the top 5 Programming languages to learn in 2021. It is always confusing for a beginner to choose a programming language from th...
True or False… While Loops Have Boolean Conditions?
It’s all about deciding what you want to create and what technology you want to work with. One of the hardest parts of becoming a programmer is simply deciding what programming language you should learn. There are so many to choose from! You become curious and next thing you know you’re learning nothing more than the syntax and some algorithms of like 5 different languages just to feel as lost as you were when you first starte