C# Check Whether the Entered Number is a Amicable Number or Not

Amicable numbers are two numbers so related that the sum of the proper divisors of the one is equal to the other, unity being considered as a proper divisor but not the number itself.

using System;

namespace Program
{
    class Program
    {
        public static void Main(String[] args)
        {
            int num1, num2, sum1 = 0, sum2 = 0, i;

            Console.WriteLine("Enter First Number: ");
            num1 = Convert.ToInt16(Console.ReadLine());

            Console.WriteLine("Enter Second Number: ");
            num2 = Convert.ToInt16(Console.ReadLine());

            for (i = 1; i < num1; i++)
            {
                if (num1 % i == 0)
                {
                    sum1 = sum1 + i;
                }
            }

            for (i = 1; i < num2; i++)
            {
                if (num2 % i == 0)
                {
                    sum2 = sum2 + i;
                }
            }

            if (num1 == sum2 && num2 == sum1)
            {
                Console.WriteLine("They are a pair of amicable numbers.");
            }
            else
            {
                Console.WriteLine("They are not amicable numbers.");             

            }
           
             Console.ReadLine();
        }
    }
}

 

Output