public
Created

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. http://projecteuler.net/problem=4

  • Download Gist
PEProblem4.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
public class worker
{
public worker(){
}
public void start()
{
int MAX_NUMBER = 999;
for (int Number = MAX_NUMBER; Number >= 0; Number--)
{
string SNumberLeft = Number.ToString();
string SNumberRight = Reverse(Number.ToString());
int palindromic = Convert.ToInt32(SNumberLeft + SNumberRight);
 
for (int i = MAX_NUMBER; i >= 1; i--)
{
for (int l = MAX_NUMBER; l >= 1; l--)
{
if ((i * l) - palindromic == 0)
{
System.Diagnostics.Debug.WriteLine("Result :" + palindromic);
return;
}
}
}
 
// System.Diagnostics.Debug.WriteLine( palindromic);
}
}
 
public string Reverse(String s)
{
char[] arr = s.ToCharArray();
Array.Reverse(arr);
return new string(arr);
}
 
 
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.