total no. of pegs : 9
total pictures : 7
so the total no. of ways in which 7 pictures may be hanged on 9 pegs will be similar to the no. of ways in which 7 balls can be filled into 9 boxes , including the case that they can be permuted also i.e... when we have selected 7 boxes to be filled with 7 balls then we can also change the ways in which a particular ball is filled in a box as every ball can be filled in any of the 7 selected boxes .
so this will be equal to the no. of different permutations in which 7 pictures can be hanged on 9 pegs .
i.e.... 9P7 = 9P9-7 = 9P2
9P2 = 9! / 2! ans.