countBlueTiles 🌶️
A gym floor is tiled in rows rows of cols tiles. The rows and columns are numbered from 0, and the tile in row r and column c is painted blue when r + c is even. (So the top-left tile is blue, and the colors alternate like a checkerboard.)
Write a method countBlueTiles that takes rows and cols (both 1 or more) and returns how many tiles are blue.
For example, countBlueTiles(3, 3) is 5.
Visit every tile with two loops, one for the row and one for the column. Where does the tile get counted?
Inside the inner loop,
if ((r + c) % 2 == 0) add one to a counter. Return the counter after both loops are finished.