Given a positive integer N. The task is to find the value of 3rd digit from last (right-most) of 5N.
Input : N = 6 Output : 6 Explanation : Value of 56 = 15625. Input : N = 3 Output : 1 Explanation : Value of 53 = 125.
Approach : Before moving to actual approach, some facts regarding number theory are listed below as:
- 53 is the smallest 3 digit number which is power of 5.
- As 125 * 5 = 625, this conclude that multiple of number (ending with 125) with 5 always construct 625 as last three digit of result.
- Again as, 625 * 5 = 3125, this conclude that multiple of number (ending with 625) with 5 always construct 125 as last three digit of result.
Hence, the final general solution is :
case 1: if n < 3, answer = 0.
case 2: if n >= 3 and is even , answer = 6.
case 3: if n >= 3 and is odd , answer = 1.
Below is the implementation of the above approach:
- Count of Numbers in Range where first digit is equal to last digit of the number
- Find the remainder when First digit of a number is divided by its Last digit
- Count 'd' digit positive integers with 0 as a digit
- Largest number less than N with digit sum greater than the digit sum of N
- Count n digit numbers not having a particular digit
- Check if frequency of each digit is less than the digit
- Generate a number such that the frequency of each digit is digit times the frequency in given number
- Last non-zero digit of a factorial
- Numbers having difference with digit sum more than s
- K-th digit in 'a' raised to power 'b'
- 3-digit Osiris number
- Find the Number which contain the digit d
- Product of N with its largest odd digit
- Least Greater number with same digit sum
- Program for replacing one digit with other
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.