Given two large or small numbers, the task is to find the last digit of the product of these two numbers.
Input: a = 1234567891233789, b = 567891233156156 Output: 4 Input: a = 123, b = 456 Output: 8
Approach: In general, the last digit of multiplication of 2 numbers a and b is the last digit of the product of the LSB of these two numbers.
For example: For a = 123 and b = 456,
the last digit of a*b
= Last digit of ((LSB of a)*(LSB of b))
= Last digit of ((3)*(6))
= Last digit of (18)
Below is the implementation of the above approach:
Time Complexity: O(1).
- Find Last Digit of a^b for Large Numbers
- First digit in product of an array of numbers
- Largest palindrome which is product of two n-digit numbers
- Check if all sub-numbers have distinct Digit product
- Check whether a number can be expressed as a product of single digit numbers
- Recursive sum of digit in n^x, where n and x are very large
- Count of Numbers in Range where first digit is equal to last digit of the number
- Digit - Product - Sequence
- Product of N with its largest odd digit
- Count n digit numbers not having a particular digit
- Maximum number with same digit factorial product
- Check if the product of digit sum and its reverse equals the number or not
- Maximum of sum and product of digits until number is reduced to a single digit
- Sum of two large numbers
- GCD of two numbers when one of them can be very large
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.