Power of K in N! where K may be Non Prime
Submissions: 175   Accuracy:

21.15%

  Difficulty: Easy   Marks: 2

Find the power of K in the factorial N.

Input:
The first line of the test case contains an integer T denoting the number of test cases. Each of the test case contains two space separated integers N and K.


Output:
For each of the test case print power of K in the factorial of N.


Constraints:
1<=T<=4.2*10^3
1<=N<=10^5
1<=K<=100

Example:
Input

2
7 2
10 9
Output
4
2

** For More Input/Output Examples Use 'Expected Output' option **

Author: ShivamKD


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.