Skip to content

Instantly share code, notes, and snippets.

@Dinner1111
Last active August 29, 2015 14:08
Show Gist options
  • Save Dinner1111/e301af2af57e9d75744f to your computer and use it in GitHub Desktop.
Save Dinner1111/e301af2af57e9d75744f to your computer and use it in GitHub Desktop.
using System;
namespace ProjectEuler
{
class Problem_4
{
/*
* 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 static void Run()
{
int multiple_1 = 100;
int multiple_2 = 100;
long largest = 0;
while (multiple_1 < 1000)
{
while (multiple_2 < 1000)
{
if (isPallindromic(multiple_1 * multiple_2)
largest = multiple_1 * multiple_2;
multiple_2++;
}
multiple_1++;
}
Console.WriteLine(largest);
Console.ReadKey();
}
private static bool isPallindromic(int number)
{
string num = number.ToString();
string reverse = "";
for (int index = num.Length - 1; index > -1; index--)
reverse += num[index];
if (num == reverse)
return true;
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment