A.1. Coding and software development
A.1.1. FizzBuzz
Write a program that prints the numbers 1 to 100. But for multiples of 3, print "Fizz" instead of the number, and for the multiples of 5, print "Buzz". For numbers that are multiples of both 3 and 5, print "FizzBuzz".
Example Answer
Here is pseudocode for one solution to the problem:
for (i in 1 to 100) { if (i mod 15) { print("FizzBuzz") } else if (i mod 5) { print("Buzz") } else if (i mod 3) { print("Fizz") } else { print(i) } }
The program iterates through the numbers 1 to 100. For each iteration, it first checks whether the number is divisible by 15, and if so, it prints “FizzBuzz”. If not, it checks whether the number is divisible by 5 and, if so, prints “Buzz”. If not, it checks ...
Get Build a Career in Data Science now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.