Will someone please explain and show

how to work this one:

How many different whole numbers can be made with the digits 5, 7, 8? For this problem, each different whole number may have 1, 2, or 3 digits and a digit may be repeated.

With one digit, there are three possibilities, 5, 7 and 8

With two digits, there are 3^2 = 9 possibilites:
55, 57, 58
75, 77, 78,
85, 87, 88.

With three digits, there are 3^3 = 27 possibilities.

3 + 9 + 27 = 39