Confused about method

I couldn’t follow the method used.Please elaborate a little more or refer me any theorem for the above challenge

Solve this problem with the logic that the highest power of k present in n! is the total number of occurrences of k in n!.
e.g.
for n = 5 and k = 2
occurrences of 2 :-
1 -> 0
2 -> 1
3 -> 0
4 -> 2
5 -> 0
total = 3, so highest power of k in n! would be 3 &
5! % 2^3 = 0.

Don’t forget to take care of the case where k>n
Test case :
1
5 8
Output should be 1

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.