Project Euler – Problem 4


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

Problem:
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.

My Solution:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Euler
{
    class Problem4 : IProblemBase
    {

        //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.

        public Problem4()
        {         

        }

        public string GetAnswer()
        {
            int result = 0;

            for (int i = 1; i <= 999; i++)
            {
                int toCompare = 0;
                for (int j = 1; j <= 999; j++)
                {
                    toCompare = i * j;

                    string s = toCompare.ToString();
                    char[] c = s.ToCharArray();
                    char[] cReversed = new char[c.Length];
                    for (int k = 0; k  result)
                        {
                            result = test;
                        }
                    }

                }

            }

            return result.ToString();
        }
    }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: