# Greatest 3-digit Palindrome Number

DharmiL Sanghvi

Greenhorn

Posts: 8

posted 2 years ago

- 0

Hey guys i have wrote the code to find Greatest Palindrome 3-digit number.

it just doesnt display greatest, it displays all the palindrome numbers encountered.

i Just want you guyz to help me out here :

1) how do i find greatest number in this

2) i've used compare method, is there any other method that can reduce computation & memory of the programme, please feel free to share it.

Here goes the code :

Array is not being used in the programme, but i've kept it because i had plans of doing it through arrays, but coudnt find a way to break the number & store it in array.

Any suggestion for my code would be greatly appreciated

please guyz help me out

it just doesnt display greatest, it displays all the palindrome numbers encountered.

i Just want you guyz to help me out here :

1) how do i find greatest number in this

2) i've used compare method, is there any other method that can reduce computation & memory of the programme, please feel free to share it.

Here goes the code :

Array is not being used in the programme, but i've kept it because i had plans of doing it through arrays, but coudnt find a way to break the number & store it in array.

Any suggestion for my code would be greatly appreciated

please guyz help me out

posted 2 years ago

- 1

The largest palindromic number of N digits is simply 10^N - 1. That is, N consecutive nines.

But if you want to pretend you don't know that and actually have to search for it, then my advice would be to start with the largest N-digit number there is, see if it's a palindrome, and if not, then decrement it and try again, and keep doing that until you find it.

I strongly suggest that you break your program down into methods. Putting that much in one method makes it very hard to understand what your program is doing, and main() should never do more than just kick off the real work of the app.

As for putting the digits into an array, you could use / and % to get the individual digits, or you could turn it into a String and use String's methods to get individual characters.

But if you want to pretend you don't know that and actually have to search for it, then my advice would be to start with the largest N-digit number there is, see if it's a palindrome, and if not, then decrement it and try again, and keep doing that until you find it.

I strongly suggest that you break your program down into methods. Putting that much in one method makes it very hard to understand what your program is doing, and main() should never do more than just kick off the real work of the app.

As for putting the digits into an array, you could use / and % to get the individual digits, or you could turn it into a String and use String's methods to get individual characters.

posted 2 years ago

- 0

It seems from your program that you are trying to find the largest palindrome that is the product of two 3-digit numbers, which is differrent from what you are asking here. There are numerous probelms in your code. However, before we get into the code, what exactly are you trying to do?

DharmiL Sanghvi

Greenhorn

Posts: 8

posted 2 years ago

i m trying to find out the largest 3 digit Palindrome number.

The answer of this is :

906609

Thats it i m just trying to find out this number.

But i get all the list, i coudnt find a way to find largest palindrome from the outputs produced.

But all those SOP are just for my reference , otherwise i just need that number.

Can you please list all the problems with the code, i m new to this algorithm stuff.

i m just practicing here.

- 0

Jayesh A Lalwani wrote:It seems from your program that you are trying to find the largest palindrome that is the product of two 3-digit numbers, which is differrent from what you are asking here. There are numerous probelms in your code. However, before we get into the code, what exactly are you trying to do?

i m trying to find out the largest 3 digit Palindrome number.

The answer of this is :

906609

Thats it i m just trying to find out this number.

But i get all the list, i coudnt find a way to find largest palindrome from the outputs produced.

But all those SOP are just for my reference , otherwise i just need that number.

Can you please list all the problems with the code, i m new to this algorithm stuff.

i m just practicing here.

DharmiL Sanghvi

Greenhorn

Posts: 8

posted 2 years ago

No i m not trying to find that.

sorry to not properly being able to explain.

According to your example, say N=5, so 10^5=100000-1 = 99999.

No thats not i want

i want :

\

So the answer to this would be :

i Hope you all understand

- 0

Jeff Verdegan wrote:The largest palindromic number of N digits is simply 10^N - 1. That is, N consecutive nines.

But if you want to pretend you don't know that and actually have to search for it, then my advice would be to start with the largest N-digit number there is, see if it's a palindrome, and if not, then decrement it and try again, and keep doing that until you find it.

I strongly suggest that you break your program down into methods. Putting that much in one method makes it very hard to understand what your program is doing, and main() should never do more than just kick off the real work of the app.

As for putting the digits into an array, you could use / and % to get the individual digits, or you could turn it into a String and use String's methods to get individual characters.

No i m not trying to find that.

sorry to not properly being able to explain.

According to your example, say N=5, so 10^5=100000-1 = 99999.

No thats not i want

i want :

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

So the answer to this would be :

**906609**.

i Hope you all understand

Campbell Ritchie

Sheriff

Posts: 47293

52

posted 2 years ago

- 0

Take what JD told you to heart. There is no need to shout with large print, and you definitely told us the wrong requirement in your first post.

My suggestion is you need these three keys: ctrl A delete. Then you start with a sheet of paper and you work out what you are going to do. I suggest you start by working out how you can tell that an integer is palindromic. Leave everything else out, get that working, and only then consider any of the other features.

My suggestion is you need these three keys: ctrl A delete. Then you start with a sheet of paper and you work out what you are going to do. I suggest you start by working out how you can tell that an integer is palindromic. Leave everything else out, get that working, and only then consider any of the other features.

posted 2 years ago

I guess 906609 is a six digit number ... which doesn't answers your question that you want to find out largest 3 digit palindrome.

- 0

DharmiL Sanghvi wrote:

i m trying to find out the largest 3 digit Palindrome number.

The answer of this is :

906609

Thats it i m just trying to find out this number.

I guess 906609 is a six digit number ... which doesn't answers your question that you want to find out largest 3 digit palindrome.

DharmiL Sanghvi

Greenhorn

Posts: 8

posted 2 years ago

Yea i m sorry i wasnt able to properly explain what i wanted.

its :

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

- 0

Lalit Mehra wrote:DharmiL Sanghvi wrote:

i m trying to find out the largest 3 digit Palindrome number.

The answer of this is :

906609

Thats it i m just trying to find out this number.

I guess 906609 is a six digit number ... which doesn't answers your question that you want to find out largest 3 digit palindrome.

Yea i m sorry i wasnt able to properly explain what i wanted.

its :

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

DharmiL Sanghvi

Greenhorn

Posts: 8

posted 2 years ago

Yea i am sorry it was my mistake.

i started working out that way, but coudnt figure out what to do.

So did it this way

- 0

Campbell Ritchie wrote:Take what JD told you to heart. There is no need to shout with large print, and you definitely told us the wrong requirement in your first post.

My suggestion is you need these three keys: ctrl A delete. Then you start with a sheet of paper and you work out what you are going to do. I suggest you start by working out how you can tell that an integer is palindromic. Leave everything else out, get that working, and only then consider any of the other features.

Yea i am sorry it was my mistake.

working out how you can tell that an integer is palindromic

i started working out that way, but coudnt figure out what to do.

So did it this way

Campbell Ritchie

Sheriff

Posts: 47293

52

posted 2 years ago

- 0

Well, I think you have done it the wrong way. Whenever I see code that complicated, I think there must be something wrong with it, even without reading it. And thinkyou are going to end up deleting the lot.

If you can’t work out how to tell whether a number is palindromic, try turning it into a String and working out whether that is palindromic. If you search these fora, you will find a few posts every year about how to check palindromes. You should, however, write down how you intend to work out palindromicity on paper first.

Then you can create methods to test that. Get them working and only then consider the rest of the task.

Hint: I remember a recursive solution appearing here once. It is nice and elegant.

By the way: where is this question from? It looks like something they ask inProject Euler.

If you can’t work out how to tell whether a number is palindromic, try turning it into a String and working out whether that is palindromic. If you search these fora, you will find a few posts every year about how to check palindromes. You should, however, write down how you intend to work out palindromicity on paper first.

Then you can create methods to test that. Get them working and only then consider the rest of the task.

Hint: I remember a recursive solution appearing here once. It is nice and elegant.

By the way: where is this question from? It looks like something they ask inProject Euler.

DharmiL Sanghvi

Greenhorn

Posts: 8

posted 2 years ago

YeP

you are right ht equestion is from Porject Euler, but i solved the question.

i Gave them the right answer, then i m asking you people so as to do the programm more efficiently & to learn something in future

- 0

Campbell Ritchie wrote:Well, I think you have done it the wrong way. Whenever I see code that complicated, I think there must be something wrong with it, even without reading it. And thinkyou are going to end up deleting the lot.

If you can’t work out how to tell whether a number is palindromic, try turning it into a String and working out whether that is palindromic. If you search these fora, you will find a few posts every year about how to check palindromes. You should, however, write down how you intend to work out palindromicity on paper first.

Then you can create methods to test that. Get them working and only then consider the rest of the task.

Hint: I remember a recursive solution appearing here once. It is nice and elegant.

By the way: where is this question from? It looks like something they ask inProject Euler.

YeP

you are right ht equestion is from Porject Euler, but i solved the question.

i Gave them the right answer, then i m asking you people so as to do the programm more efficiently & to learn something in future

posted 2 years ago

- 0

The whole point of project euler is not to come up with the right answer, but to figure out the algorithm. Start very simple:

1) generated every possible 6 digit number

2) Test a number to see if it meets the conditions.

Note how the two are 100% independent of each other...I don't care how I got a number, but assuming I have one, I can test it. and generating all the six digit numbers doesn't care what I do with them.

So once you have that, you look at how you would do one part: Assuming you have a number, how do you test it to see if it meets your conditions? well...it has to be a palindrome, and it has to be the product of two three-digit number.

Now you know you have to do two things: 1) is the number a palindrome, and 2) is it the product of two three-digit number. Note that each of THESE are independent of each other. So, figure out how to do ONE Of those two things...

keep breaking down hte problem into component parts, and only work on one at a time.

1) generated every possible 6 digit number

2) Test a number to see if it meets the conditions.

Note how the two are 100% independent of each other...I don't care how I got a number, but assuming I have one, I can test it. and generating all the six digit numbers doesn't care what I do with them.

So once you have that, you look at how you would do one part: Assuming you have a number, how do you test it to see if it meets your conditions? well...it has to be a palindrome, and it has to be the product of two three-digit number.

Now you know you have to do two things: 1) is the number a palindrome, and 2) is it the product of two three-digit number. Note that each of THESE are independent of each other. So, figure out how to do ONE Of those two things...

keep breaking down hte problem into component parts, and only work on one at a time.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors

Lovro Bajc

Ranch Hand

Posts: 45

posted 1 year ago

- 0

Hi everyone,

I have been trying to figure this palindrome out, however no clue. Since I am at the third chapter of the book Introduction to Java programming 10th edition I have not come across the loops yet not even to how to break down the

three digit integer into three integers.

I need to write program that prompts user to enter a three-digit integer and determines whether it is a palindrome number or not.

I have been doing a bit of a searching and finally got to information how to reverse the number. There is however something wrong since if I enter the

3 digit integer which is palindrome, result is ("not a palindrome");

thanks for the assistance.

best regards

I have been trying to figure this palindrome out, however no clue. Since I am at the third chapter of the book Introduction to Java programming 10th edition I have not come across the loops yet not even to how to break down the

three digit integer into three integers.

I need to write program that prompts user to enter a three-digit integer and determines whether it is a palindrome number or not.

I have been doing a bit of a searching and finally got to information how to reverse the number. There is however something wrong since if I enter the

3 digit integer which is palindrome, result is ("not a palindrome");

thanks for the assistance.

best regards

Joanne Neal

Rancher

Posts: 3742

16

posted 1 year ago

Then, I hate to say, but you're a few weeks away from a solution yet.

Then have you considered writing a program that works out whether the

After all:

If the

AND

The

Doesn't that make the number palinodromic? (Maybe not; but I suspect so)

So, you now have TWO problems:

Is the string they entered a number? Is it a palindrome?

And (believe me) tryng to work out whether a

Winston

- 0

Lovro Bajc wrote:I have been trying to figure this palindrome out, however no clue. Since I am at the third chapter of the book Introduction to Java programming 10th edition I have not come across the loops yet not even to how to break down the three digit integer into three integers.

Then, I hate to say, but you're a few weeks away from a solution yet.

I need to write program that prompts user to enter a three-digit integer and determines whether it is a palindrome number or not.

Then have you considered writing a program that works out whether the

*String*they entered is a palindrome or not?

After all:

If the

*String*they entered is a valid number.

AND

The

*String*they entered is a palindrome.

Doesn't that make the number palinodromic? (Maybe not; but I suspect so)

So, you now have TWO problems:

And (believe me) tryng to work out whether a

*String*is a palindrome is much easier than trying to work out whether

*the number it represents*is.

Winston

I wonder how a hamster feels, out in the wild where there's no wheels -- Ogden Nash (or should've been).

Articles by Winston can be found here

I agree. Here's the link: http://aspose.com/file-tools |