【Project Euler】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
//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.
static void Main(string[] args)
{
int sum = 0;
for (int i = 10; i < 1000; i++)
{
for (int j = 10; j < 1000; j++)
{
sum = i * j;
if (sum / 100000 < 10)
{
int a = sum / 100000;
int b = (sum - a * 100000) / 10000;
int c = (sum - a * 100000 - b * 10000) / 1000;
int d = (sum - a * 100000 - b * 10000 - c * 1000) / 100;
int e = (sum - a * 100000 - b * 10000 - c * 1000 - d * 100) / 10;
int f = sum - a * 100000 - b * 10000 - c * 1000 - d * 100 - e * 10;
if (a == f && b == e && c == d)
{
if (sum > 900000)
{
Console.WriteLine(sum);
}
}
}
}
}
}
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)