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 927393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:50:48+00:00 2026-05-15T19:50:48+00:00

So on Project Euler the Problem 4 states the following: A palindromic number reads

  • 0

So on Project Euler the Problem 4 states the following:

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.

I have tried the following:

    #include <stdio.h>
    #include <stdlib.h>

    int check(int result)
    {
        char b[7];
        sprintf(b, "%d", result);
        if (b[0] == b[5] && b[1] == b[4] && b[2] == b[3])
        {
            return 1;
        }
        else 
        {
            return 0;
        }
    }

    int main () {
        int i;
        int g;
        int final;
        for (i = 999; i > 99; i--)
        {
            for (g = 999; g > 99; g--)
            {
                if (check(g*i) == 1)
                {
                    final = g*i;
                    goto here;
                }
            }
        }
        here:
        printf("%d", final);
}

But, this does not work. Instead of the right answer, I get 580085, which I guess is a palindrome at least, but still not the right answer.

Let me explain my program starting from int main:

  1. int i and int g are my multipliers. They are those two three digit numbers.
  2. int final is the number that will store the largest palindrome.
  3. I start two for loops going to down to get every number possibility.
  4. I get out of the loop using a goto when the first palindrome is reached(probably should not but, it doesn’t effect a small program like this too much).
  5. The first palindrome should be the biggest one possible since I am counting down from the top.

Let me now explain my check:

  1. First off since these are two three digit numbers multiplying together to determine the size a char would need to be to hold that value I went to a calculator and multiplied 999 * 999 and it ended up being 6 then I need to add one because I found out from one the questions I posted earlier that sprintf puts a \0 character at the end.
  2. Ok, now that I have a char and all, I copied result (which i*g in int main) and put it in char b[7].
  3. Then I just checked b to see if it equalled it self with by hard coding each slot I needed to check for.
  4. Then I returned accordingly, 1 for true, and 2 for false.

This seems perfectly logical to me but, it does not work for some weird reason. Any hints?

  • 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-05-15T19:50:49+00:00Added an answer on May 15, 2026 at 7:50 pm

    This assumption is wrong:

    The first palindrome should be the biggest one possible since I am counting down from the top.

    You will check 999*100 = 99900 before 998*101 = 100798, so clearly you can´t count on that.

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

Sidebar

Related Questions

Some of you may recognize this as Project Euler's problem number 11. The one
As stated in problem 37 at Project Euler : The number 3797 has an
I'm playing around with Project Euler's Problem 220 , and I'm a little confused
I'm trying to work through Project Euler and I'm hitting a barrier on problem
I did this problem [ Project Euler problem 5 ], but very bad manner
I am doing another Project Euler problem and I need to find when the
I am working on Project Euler Problem 4 , and need to find the
This is a Project Euler problem. If you don't want to see candidate solutions
Possible Duplicate: Project Euler, Problem 10 java solution not working So, I'm attempting to
I've been wrestling with Project Euler Problem #16 in C# 2.0. The crux of

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.