find if the given numbers are Friendly pair or not In Python

       

        find if the given numbers are Friendly pair or not 

 In Python


For example,and 28 are Friendly Pair.

(Sum of divisors of 6)/6 = (Sum of divisors of 28)/28.

Program:

    n1 = int(input("Enter First Number"))
    n2 = int(input("Enter Second Number"))
    s1 = 0
    s2 = 0
    for i in range(1,n1):
    if(n1 % i == 0):
    s1 = s1 + i
    for i in range(1,n2):
    if(n2 % i == 0):
    s2 = s2 + i
    if(s1 == n1 and s2 == n2):
    print("Friendly Pair")
    else:
    print("Not Friendly Pair")


    OutPut:
    Enter First Number6
    Enter Second Number28
    Friendly Pair


    Enter First Number6
    Enter Second Number24
    Not Friendly Pair














    No comments:

    Post a Comment