Add it tighter and it will make ur number then subtract that
Ye $5 notes be x and $1 notes be y
Equation = 5x+y = $40

check your calculator for the [!] factorial button.
also bear in mind that most calculators also have an [ₙPᵣ] button, to get Permuations, and you can just use that.