Given a value n, find out the largest palindrome number which is product of two n digit numbers.
Input : n = 2 Output : 9009 9009 is the largest number which is product of two 2-digit numbers. 9009 = 91*99. Input : n = 3 Output : 906609
Below are steps to find the required number.
1) Find a lower limit on n digit numbers. For example, for n = 2, lower_limit is 10.
2) Find an upper limit on n digit numbers. For example, for n = 2, upper_limit is 99.
3) Consider all pairs of numbers where ever number lies in range [lower_limit, upper_limit]
Below is the implementation of above steps.
The approach used in this post is simple and straightforward. Please comment if you find a better approach.
This article is contributed by Shivam Pradhan(anuj_charm). 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above
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.
- Largest palindrome which is product of two N-digit numbers : Set 2
- Sum and product of k smallest and k largest prime numbers in the array
- Sum and product of k smallest and k largest composite numbers in the array
- Smallest and Largest Palindrome with N Digits
- Product of N with its largest odd digit
- Numbers less than N which are product of exactly two distinct prime numbers
- Sum of all N digit palindrome numbers
- Sum of all palindrome numbers present in an Array
- Count of N-digit Palindrome numbers
- Find all palindrome numbers of given digits
- Sum of all Palindrome Numbers present in a Linked list
- Count the number of digits of palindrome numbers in an array
- Absolute difference between the Product of Non-Prime numbers and Prime numbers of an Array
- Nth term of a sequence formed by sum of current term with product of its largest and smallest digit
- Largest Even and Odd N-digit numbers
- Find two numbers with sum and product both same as N
- Check whether product of 'n' numbers is even or odd
- Largest number in [2, 3, .. n] which is co-prime with numbers in [2, 3, .. m]
- Smallest and Largest sum of two n-digit numbers
- Largest Even and Odd N-digit numbers of base B