;

# C# Program To Checks Whether the Both the Entered Number is a Pair of Amicable Number or Not

###### Tutorialsrack 11/08/2019 C# Programs

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 Not.

## What is an Amicable Number?

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: (220, 284), (1184, 1210), (2620, 2924), (5020, 5564), (6232, 6368), (10744, 10856), (12285, 14595), (17296, 18416), (63020, 76084), and (66928, 66992).

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

##### Code - C# Program To Checks Whether the Both the Entered Number is a Pair of Amicable Number or Not.
``````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: ");
Console.Write("\nEnter The Second Number: ");
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");
}
}
}
}``````
##### Output

Enter The First Number: 220

Enter The Second Number: 284

Both Entered Numbers is a Pair of Amicable Numbers