P18179 [GeeksforGeeks] Find the last digit when factorial of a divides factorial of b5438
普及
题目描述

Given two numbers A and B. The task is to compute the last digit of the resulting F, where F= B! / A! .
Example 1:
Input: A = 2, B = 4
Output: 2
Explaination: The value of F = 12. So the
last digit is 2.
Example 2:
Input: A = 3, B = 8
Output: 0
Explaination: F is 6720. So the last value
is 0.
Your Task:
You do not need to read the input or print anything. Your task is to complete the function lastDigit() which takes A and B and returns the last value of F.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ A ≤ B ≤ 10^{18}

输入格式

见题面

输出格式

见题面

样例输入
A = 2, B = 4
样例输出
2