Well, you can get all fancy with recursive solutions, but if I were your teacher, I'd give the most credit to a solution that
merely counts from 0 to 7 and uses the bit pattern to decide
which things to include and which things to leave out. That's an algorithm you could probably get someone else to understand and maintain.