views:

123

answers:

2

Hi this is the question ,really I have thought a lot but I think that we can not answer such a question in java.is it correct?

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.

Find the largest palindrome made from the product of two 3-digit numbers.

(question here)

+1  A: 

'think a bit harder' is the only sane advice I can offer.

Gareth Davis
A: 

No, it's not correct.

It's a little difficult with Java, but it's not correct.

The basic modus operandi for solving ANY problem should always be to divide the problem into parts, and then solve the parts.

For example, you need to be able to see if a number is a palindrome. So write a function that converts the number into a string, and then checks if it's a palindrome.

Then you need to write a loop that will try all possible 3-digit number multiplications, and each of those multiplications need to be checked with your palindrome check function.

When you've found a palindrome, you may need to store it and then extract the largest of those palindromes. (Or you may not need to do this, if you think about what order you should test values in)

Try solving the problem one step at a time, and not necessarily in order. Use method separation to separate code by function, putting special focus on anything that might need to be repeated (like checking if a number is a palindrome). It requires lots of thought and even more tinkering with code, but this problem is quite doable in Java.

Platinum Azure