# Python program to check whether two numbers are Friendly Pair

## Friendly Pair

Here, in this section we will discuss the Python program to check whether two numbers are friendly pair or not. Friendly pair or Amicable numbers are two different numbers related in a way such that the sum of the proper divisors of each is equal to the other number. A proper divisor is a positive factor of that number other than the number itself ,for Example proper divisors of 6 are 1, 2, and 3.

Example:

• n=6 , m=28
• Divisor of 6 are 1, 2, 3, 6.
Divisor of 28 are 1, 2, 4, 7, 14, 28. Sum of divisor of 6 and 28 are 12 and 56 respectively. Abundancy index of 6 and 28 are 2. So they are friendly pair.
• n=18 , m=7
• They are not friendly pair. ### Implementation:

• Find the sum of divisors of n and then of m .
• Find the abundancy idex of both the number say x and y.
• If x==y then it is Friendly pair else not .

## Python Code:

`#'Enter the numbers to check'n=int(input())m=int(input())import math sum_n=1 + n  #sum of divisor of n sum_m=1 + m  #sum of divisor of mi=2 j=2 #finding divisorwhile(i<=math.sqrt(n)):    if(n%i==0):        if(n//i==i):            sum_n+=i         else:            sum_n+=i + n//i                i=i+1     while(j<=math.sqrt(m)):    if(m%j==0):        if(m//j==j):            sum_m+=j             else:            sum_m+=j + m//j                 j=j+1 if(sum_n/n==sum_m/m):    print('Yes' , n , ',' , m ,' are friendly Pair') else:    print('No', n , ',' , m ,' are not friendly Pair')`
`Input:628Output:Yes 6 , 28 are friendly Pair`