The standard Rule is :
" A system with m resources of same type being shared by n processes. Resources can be requested and released by processes only on at a time .
The system is deadlock free if and only if --> The sum of all max needs is < m+n "
Now here in this question
1. n processes each requiring 4 resources. So total maximum need are 4n.
2. There are 21 resources are in total which is shared by n processes.
so applying above stated Rule
4n < 21+n
=> 3n< 21
=> n < 7 hence number of process must be less than 7 , which is 6 at maximum .( asked in the question) .