Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8256395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:51:08+00:00 2026-06-08T01:51:08+00:00

I was trying Project Euler and am stuck on this one: A palindromic number

  • 0

I was trying Project Euler and am stuck on this one:

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.

for i in range(1000,100,-1):
    for j in range(1000,100,-1):
        test = i*j
        test = str(test)                #turn product into string
        test2 = test[2:]                #take last two numbers
        test2 = test2[::-1]             #flip them
        if test[:2] == test2:           #if it's a palindrome, the first two should 
            print(i, "\t", j)           #match the flip of last two

input("\n\nPress the ENTER key to exit.")

Nothing happens when it is run: the command line calculates, but doesn’t print anything. The program does end though.

I know the bigger numbers have more than just the first and last two numbers, but there should be few enough palindromes that I can just look through them.

Here is the next one:

Find the Pythagorean triplet whose sum is 1000.
a^2 + b^2 = c^2, a+b+c=1000

for a in range(1,32):
    for b in range(1,32):
        c = (a**2 + b**2)**.5
        if a + b + c == 1000:
            print(a,"\t",b,"\t",c)
input("\n\nPress the ENTER key to exit.")

As with the last program, there is no output… But again, it does end.
But I noticed that they both have nested for loops. Could this have something to do with it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:51:09+00:00Added an answer on June 8, 2026 at 1:51 am

    Both your tests are wrong. In the first example, the line

    test2 = test[2:]                #take last two numbers
    

    does not say what the comment says – this line strips off the first two characters from the string, leaving only the last digit. Instead of fixing this line, simply check if the whole string equals the reversed string:

    if test == test[::-1]:
    

    In the second example, you compare approximate floating point numbers to the exact integer 1000. Since the floating-pointed numbers will have rounding errors, you don’t find an exact match. See also Floating Point Arithmetic: Issues and Limitations in the Python tutorial.

    You should round c to the nearest integer, check if they really are a Pythagorean triple using pure integer arithmetic and then test if the sum is 1000.

    As pointed out by DSM in the comments, your loops also stop to early. the maximum sum you will find with these values is about 106.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to solve this Project Euler question : A perfect number is
Some of you may recognize this as Project Euler's problem number 11. The one
I am currently trying out Project Euler and one of the question is calculate
I'm trying to solve the 8th problem of the project Euler and I'm stuck
I'm trying to complete this Project Euler challenge: By listing the first six prime
I was trying to solve this Project Euler Question . I implemented the sieve
I'm trying to solve questions from Project Euler in Ruby one-liners, and I'm curious
I'm trying to do project Euler number 219 but am failing to get a
I am trying to do problem 254 in project euler and arrived at this
I've become very addicted to Project Euler recently and am trying to do this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.