/// <summary>
        /// Count the number of integers in a list that are palindromes and both the original number and the palindrome are prime.
        /// </summary>
        /// <param name="list">The list of integers to process</param>
        /// <returns>the count</returns>
        public static int CountPalindromesWhereBothArePrime(List <long> list)
        {
            int palindromePrimeCount = 0;

            foreach (long num in list)
            {
                if (IsPrimeClass.IsPrime(num) == true && IsPalindromeClass.IsPalindrome(num) == true)
                {
                    palindromePrimeCount++;
                }
            }
            return(palindromePrimeCount);
        }
示例#2
0
        /// <summary>
        /// Count the palindromes in a list of integers
        /// </summary>
        /// <param name="list">The list of numbers to process</param>
        /// <returns>The count of integers in list that are palindromws</returns>
        public static long  CountPalindromes(List <long> list)
        {
            long result = 0;

            //for each number in list
            foreach (long num in list)
            {
                //if the number is prime, increase the result by 1
                if (IsPalindromeClass.IsPalindrome(num))
                {
                    result++;
                }
            }

            return(result);
        }