Why Might My Palindrome Calculation Be Incorrect?

  • Context: Undergrad 
  • Thread starter Thread starter rwinston
  • Start date Start date
Click For Summary
SUMMARY

The discussion centers on the palindrome calculation from Project Euler problem #4, which seeks the largest palindrome made from the product of two three-digit integers. The correct answer is 906609, while the user initially calculated 997799. The flaw in the user's logic was starting from 999^2 and counting down without ensuring that each palindrome found was a product of two three-digit integers. The user later recognized that 997799 = 11 x 90709 does not meet the criteria of being a product of two three-digit integers.

PREREQUISITES
  • Understanding of palindrome properties in numbers
  • Familiarity with Project Euler problems
  • Basic knowledge of integer factorization
  • Experience with programming logic for iterative calculations
NEXT STEPS
  • Review the implementation of nested loops to find products of two three-digit integers
  • Learn about efficient palindrome checking algorithms
  • Explore integer factorization techniques for verifying products
  • Study optimization strategies for solving Project Euler problems
USEFUL FOR

Mathematicians, programmers, and enthusiasts interested in algorithm design, particularly those tackling Project Euler challenges or working on palindrome-related problems.

rwinston
Messages
36
Reaction score
0
Hi all

I was looking q # 4 on ProjectEuler.net, and it is a problem to find the largest palindrome constructed from the product of two three-digit integers.

Now, the answer (spoilers, if you don't want to know ) is 906609. However, I got a different answer, but possibly my logic is incorrect. Can anyone spot a flaw in the following reasoning:

As the upper bound of 2 3-digit numbers, I chose 999^2 = 998001. Hence, by counting down from this to a lower limit (say 100) I should have all of the 3-digit integer products in this range? Thus, by starting at the upper limit and counting down, and then testing each integer at every step for the palindrome property, I should find the largest.

I found a palindrome, 997799 which is > the given answer and < 999^2. However, I can't see the flaw in my logic which would imply that this is incorrect and the given answer is correct. Can anyone point me in the right direction? Thanks!

Edit: ok, I think I may have seen the flaw...I guess starting at N^2 and working down is not correct as, I can't guarantee that the factorization at each step is two three-digit integers.
 
Last edited:
Physics news on Phys.org
You found it. 997799 = 11 x 90709 is not the product of two three-digit integers.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 8 ·
Replies
8
Views
8K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K