Given eight digits of a phone number as an integer N, the task is to find the missing last two digits and print the complete number when the last two digits are the sum of given eight digits.
Input: N = 98765432
Input: N = 10000000
- Get the eight digits of the phone number from N one by one using the Modulo 10 operator (%10).
- Add these digits in a variable say sum to get the sum of the eight digits.
- Now, there are two cases:
- If sum < 10 then it is a single digit i.e. insert 0 in the beginning to make it a two digit number without affecting the value.
- Else sum is the number represented by the last two digits.
Below is the implementation of the above approach:
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Print all possible words from phone digits
- Java ArrayList to print all possible words from phone digits
- Find smallest number with given number of digits and sum of digits under given constraints
- Find the repeating and the missing number using two equations
- Find the missing number in Arithmetic Progression
- Find the average of k digits from the beginning and l digits from the end of the given number
- Find the missing number in unordered Arithmetic Progression
- Find the missing number in a string of numbers with no separator
- Find the missing number in a sorted array of limited range
- Find the smallest positive number missing from an unsorted array | Set 3
- Find the Largest number with given number of digits and sum of digits
- Find smallest possible Number from a given large Number with same count of digits
- Find the number of positive integers less than or equal to N that have an odd number of digits
- Find count of digits in a number that divide the number
- Find the smallest number whose digits multiply to a given number n
- Find maximum number that can be formed using digits of a given number
- Given a number n, find the first k digits of n^n
- Find first and last digits of a number
- Find Next number having distinct digits from the given number N
- Find M-th number whose repeated sum of digits of a number is N
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.