示例#1
0
        public static void ReverseAndAdd(Palindrome input)
        {
            var reverse = Reverse(input.Answer);

            // check if palindrome is found
            if (input.Answer == reverse)
            {
                return;
            }

            // check if the number of times excuted
            if (input.Count >= 1000)
            {
                input.Answer = "Maximum counts reached. Excution halted.";
                return;
            }

            var add = Add(input.Answer, reverse);

            // index out of range
            if (add > 4294967295)
            {
                input.Answer = "Maximum palindrome reached. Excution halted.";
                return;
            }

            input.Answer = add.ToString();
            input.Increment();

            ReverseAndAdd(input);
        }