我已经成功地确定了哪两个数字相乘时会在 C# 中产生数字回文,但是我需要将产品从最低到最高排序。有没有办法做到这一点?
static void LargestPalindrome()
{
ulong product = 0;
ulong compare = 0;
for (uint i = 100; i < 1000; i++)
{
for (uint j = 100; j < 1000; j++)
{
product = i * j;
StringBuilder value = new StringBuilder(product.ToString());
//Pass string to reverse
string value_r = Reverse(value.ToString());
//Check if Numeric Palindrome
if(value_r.Equals(value.ToString()) && product>compare)
{
Console.WriteLine("{0} x {1} = {2} in reverse {3}", i, j, value, value_r);
}
}
}
}