Explore
ProGrad Programs
Placement Prep
TCS Codevita
Webinars
About Us

Edit
Reply




Edit

Program to find if the given numbers are Friendly pair or not (Amicable or not)

Published on 10 Mar 2020

Program to find if the given numbers are Friendly pair or not (Amicable or not) is discussed here. Friendly Pair are two or more numbers with a common abundance.


Input & Output format:


  • Input consists of 2 integers.
  • The first integer corresponds to number 1 and the second integer corresponds to number 2.
  • If it is a Friendly Pair display Friendly Pair or displays Not Friendly Pair.


For example,6 and 28 are Friendly Pair.

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


Algorithm to check whether the given numbers are friendly pair or not


  • Input the numbers num1 and num2.
  • Initialize sum1 = sum2 = 0.
  • sum1 = sum of all divisors of num1.
  • sum2 = sum of all divisors of num2.
  • If (sum1 == num1) and (sum2 == num2), then print "Abundant Numbers".
  • Else, print "Not Abundant Numbers".


Program to check whether the given numbers are friendly pair or not


C
C++
Java
Python 3

Output
6
28
Friendly Pair


Recommended Programs










If you have any feedback about this article and want to improve this, please write to enquiry@faceprep.in