示例#1
0
        public static int DoubleBasePalindromes(int n)
        {
            int sum = 0;

            for (int i = 1; i < n; i++)
            {
                string binary = Convert.ToString(i, 2);
                if (CombinatoricFunctions.IsPalindrome(i) && CombinatoricFunctions.IsPalindrome(binary))
                {
                    sum += i;
                }
            }
            return(sum);
        }
示例#2
0
        public static int LargestPalindromeProduct(int n)
        {
            int largest = 0;

            //Loop through every combination of numbers until n
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    //If i*j is a palindrome then check if it's largest then the largest so far and set it to an int
                    if (CombinatoricFunctions.IsPalindrome(i * j))
                    {
                        if ((i * j) > largest)
                        {
                            largest = i * j;
                        }
                    }
                }
            }
            return(largest);
        }