Factorial equations

3.4

57 votes
Mathematics, Modulus Arithmetic, Math, Number Theory
Problem

You are given two numbers \(X\) and \(N\). Your task is to find the last digit of the following equation: 
\(X^{((N!)\div mod\ 10)}\)

Input format

The first line contains two integers \(X\) and \(N\).

Output format

Print the last digit of the given equation.

Constraints

\(1 \leq X \leq 10^9\\ 0 \leq N \leq 10^{18}\)

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

factorial of (2) is 2*1=2  ,So 5^2=25 the last digit in 25 is 5

Editor Image

?