【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 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);
                            }
                        }
                    }
                }
            }
        }

时间: 2024-11-13 09:15:31

【Project Euler】4 第四题的相关文章

【Project Euler】1 第一题

 //If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. //Find the sum of all the multiples of 3 or 5 below 1000.  static void Main()         {             int sum=0;     

【Project Euler】2 第二题

 //Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: //1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... //By considering the terms in the Fibonacci sequence whose valu

【Project Euler】9 第九题

 A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. static void Main(s

使用CoffeeScript来解决Project Euler中的编程问题

本 系列 文章将探讨 CoffeeScript,这是构建于 http://www.aliyun.com/zixun/aggregation/33906.html">JavaScript 基础之上的一种全新编程语言,它提供了非常干净的语法.CoffeeScript 可编译为高效的 JavaScript.除了在 Web 浏览器中运行 JavaScript 之外,您还可以将它与服务器应用程序的 Node.js 等技术一起使用.在 第 1 部分 中,学习了如何设置 CoffeeScript 编译器

用python解决project euler中的题目

寒假期间学习了python,现在基本上就能上手使用它来解决project euler里面的题目了,用python真的是没得说的,一个字"赞".在C++中需要用一大堆代码实现的算法,在python中,只需要那么短短几行.而且还有惊艳的运行速度.借用<可爱的python>里面的一句话:"人生苦短,我用python". [project euler 055] 求经过一系列规则不能得到回文数的数的个数.题目在此: If we take 47, reverse a

Project euler 18题解答

 By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 37 4 2 4 6 8 5 9 3 That is, 3 + 7 + 4 + 9 = 23. Find the maximum total from top to bottom of the triangle below

【Project Euler】7 第七题

 //By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. //What is the 10 001st prime number? static void Main(string[] args)         {             int count = 0;             for (int i = 3; i < 100000

【Project Euler】5 第五题

 //2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. //What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?         static void Main(string[] args

【Project Euler】3 第三题

 //The prime factors of 13195 are 5, 7, 13 and 29.         //What is the largest prime factor of the number 600851475143 ?         static void Main(string[] args)         {             //int[] number = new int[100];             long[] number = new