Kotlinlearncs.online LogoJava
Return to List

Homework: Dominos

Created By: Chris Taylor
/ Version: 2023.7.0

Suppose we have a 2 x n checkerboard (two rows and n columns). Write the recursive method, dominos, that, given n, returns the number of possible ways in which we can cover the board with 1 x 2 dominos. For example:

            |
n = 1 -> 1  |

            ||   --
n = 2 -> 2  ||   --

            |||   --|   |--
n = 3 -> 3  |||   --|   |--

If n is less than zero, throw an IllegalArgumentException

Related Lessons

Stuck? You may find these lessons helpful: