From the course: Go Essentials: Concurrency, Connectivity, and High-Performance Apps
Unlock the full course today
Join today to access over 24,600 courses taught by industry experts.
Solution: FizzBuzz - Go Tutorial
From the course: Go Essentials: Concurrency, Connectivity, and High-Performance Apps
Solution: FizzBuzz
(exciting music) - [Instructor] Let's see my solution. So we have function main and here we are doing a loop between I equal one, I less than or equal to 20, I plus plus. And first we check if it's divisible by both three and five and if it's so, then we are printing fizz buzz. Otherwise, if it's divisible by three, we are printing fizz. Otherwise, if it's divisible by five, we are printing buzz. And finally we print the number. Let's run. And we see that we get the numbers. So one, two, instead of three, we have fizz, instead of four, we have buzz, et cetera, et cetera. And in 15, which divides by both three and five, we have fizz buzz.
Contents
-
-
-
-
Numbers and assignments3m 52s
-
(Locked)
Conditionals2m 35s
-
(Locked)
For loops2m 5s
-
(Locked)
Challenge: FizzBuzz57s
-
(Locked)
Solution: FizzBuzz55s
-
(Locked)
Strings2m 59s
-
(Locked)
Challenge: Even-ended numbers55s
-
(Locked)
Solution: Even-ended numbers53s
-
(Locked)
Slices2m 34s
-
(Locked)
Challenge: Find the maximal value12s
-
(Locked)
Solution: Find the maximal value41s
-
(Locked)
Maps2m 37s
-
(Locked)
Challenge: Maps26s
-
(Locked)
Solution: Maps57s
-
-
-
-
-
-
-
-