In this C# program, we will learn how to write a program to checks whether both the entered number is a pair of * Amicable Number *or

* Amicable numbers* are two different numbers so related that the sum of the proper divisors of each is equal to the other number. In Other Words, A proper divisor of a number is a positive factor of that number other than the number itself. For example, the best possible divisors of 6 are 1, 2, and 3.

The smallest pair of * amicable numbers* is (220, 284). They are amicable because:

- The proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110, of which the sum is 284;
- and the proper divisors of 284 are 1, 2, 4, 71 and 142, of which the sum is 220.

The first ten * amicable pairs* are:

Here is the code of the program to checks whether both the entered number is a pair of * Amicable Number *or

```
using System;
namespace TutorialsrackPrograms
{
class Program
{
//C# Program Checks Whether the Both the Entered Number is a Pair of Amicable Number or Not.
static void Main(string[] args)
{
int number1, number2, sum1 = 0, sum2 = 0, i;
Console.Write("Enter The First Number: ");
number1 = int.Parse(Console.ReadLine());
Console.Write("\nEnter The Second Number: ");
number2 = int.Parse(Console.ReadLine());
for (i = 1; i < number1; i++)
{
if (number1 % i == 0)
{
sum1 = sum1 + i;
}
}
for (i = 1; i < number2; i++)
{
if (number2 % i == 0)
{
sum2 = sum2 + i;
}
}
if (number1 == sum2 && number2 == sum1)
{
Console.WriteLine("Both Entered Numbers is a Pair of Amicable Numbers");
}
else
{
Console.WriteLine("Both Entered Numbers is not a pair of Amicable Numbers");
}
Console.Read();
}
}
}
```

Enter The First Number: 220

Enter The Second Number: 284

Both Entered Numbers is a Pair of Amicable Numbers

## Comments