Last Factorial Digit

면접 대비

시간 제한1초메모리 제한1024 MB

요약
N이 10 이하인 최대 10개의 입력에 대해 N!의 일의 자리 숫자를 출력한다.
난이도

쉬움10점 중 2점

유형
수학, 완전 탐색
정답자
아직 제출이 없습니다

문제

The factorial of NN, written as N!N!, is defined as the product of all the integers from 11 to NN. For example, 3!=1×2×3=63! = 1 \times 2 \times 3 = 6.

This number can be very large, so instead of computing the entire product, just compute the last digit of N!N! (when N!N! is written in base 1010).

입력

The first line of input contains a positive integer 1≤T≤101 \leq T \leq 10, the number of test cases. Each of the next TT lines contains a single positive integer NN. NN is at most 1010.

출력

For each value of NN, print the last digit of N!N!.

예제2

  1. 예제 1

    입력
    3
    1
    2
    3
    
    예상 출력
    1
    2
    6
    
  2. 예제 2

    입력
    2
    5
    2
    
    예상 출력
    0
    2