Coding challenges
In the following 15 coding challenges, we will focus on the most popular problems from the math and logical puzzles category. Let's get started!
Coding challenge 1 – FizzBuzz
Adobe, Microsoft
Problem: Consider you've been given a positive integer, n. Write a problem that prints the numbers from 1 to n. For multiples of five, print fizz, for multiples of seven, print buzz, and for multiples of five and seven, print fizzbuzz. Print a new line after each string or number.
Solution: This is a simple problem that relies on your knowledge of division and the Java modulus (%) operator. When we divide two numbers, the dividend and the divisor, we get a quotient and the remainder. In Java, we can obtain the remainder of a division via the modulus (%) operator. In other words, if X is the dividend and Y is the divisor, then X modulus Y (written in Java as X % Y) returns the remainder of dividing X by Y. For example, 11(dividend) / 2(divisor) = 5...