Given an array of n elements and elements are  from 1 to n-1. that is

clip_image002[6]

Code

        public static void PrintDuplicate(int[] input)
        {
            int length = input.Length;
            Console.WriteLine(string.Join(";", input));
            for (int i = 0; i < length; i++)
            {
                if (input[Math.Abs(input[i])] >= 0)
                {
                    input[Math.Abs(input[i])] = -input[Math.Abs(input[i])];

                }
                else
                {
                    Console.WriteLine("duplicate number {0} and it's index is {1} ",
Math.Abs(input[i]), i + " ; "); } } }