Timer is Running

Find unit digit in a Product
Submissions: 15   Accuracy:

20%

  Difficulty: Easy   Marks: 2

Given 6 numbers a,b,c,d,e,f. Find the last digit of (ab)*(cd)*(ef).

 

Example 1:

Input:
a = 3 
b = 66 
c = 6 
d = 41 
e = 7 
f = 53
Output:
8
Explanation:
The last digit of the 
value obtained after 
solving the above 
equation is 8.

 

 

Example 2:

Input:
a = 1 
b = 1 
c = 1 
d = 1 
e = 1 
f = 1
Output:
1
Explanation:
The last digit of the 
value obtained after 
solving the above 
equation is 1.

 

 

Your Task:

You don't need to read input or print anything. Your task is to complete the function theLastDigit() which takes 6 integers a, b, c, d, e, and f and returns the last digit of the value obtained from the equation.

 

Expected Time Complexity: O(sqrt(N))
Expected Auxiliary Space: O(1)

 

Constraints:
1 <= a,b,c,d,e,f <= 109

 

** 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.