Given a number n, find the last non-zero digit in n!.
Input : n = 5 Output : 2 5! = 5 * 4 * 3 * 2 * 1 = 120 Last non-zero digit in 120 is 2. Input : n = 33 Output : 8
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains an integer n.
For each test case in a new line print the required output.
1 <= T <= 100
1 <= n <= 100
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.