Home > Java > A Program In Java To Identify A Number Is Amicable Or Not
So this project is based on Amicable Number,
In this section, we will learn what is an amicable number and also create Java programs to check whether the given numbers is an amicable number or not.
Note :-The amicable number programs are frequently asked in Java coding tests and academics. So be careful.
What is an Amicable Number ?
Amicable numbers are two different natural numbers related in such a way that the sum of the proper divisors of each is equal to the other number. That is, σ(a)=b and σ(b)=a, where σ(n) is equal to the sum of positive divisors of n (see also divisor function).
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. (A proper divisor of a number is a positive factor of that number other than the number itself. For example, the proper divisors of 6 are 1, 2, and 3.)
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). (sequence A259180 in the OEIS). (Also see OEIS: A002025 and OEIS: A002046) It is unknown if there are infinitely many pairs of amicable numbers.
A pair of amicable numbers constitutes an aliquot sequence of period 2. A related concept is that of a perfect number, which is a number that equals the sum of its own proper divisors, in other words a number which forms an aliquot sequence of period 1. Numbers that are members of an aliquot sequence with period greater than 2 are known as sociable numbers.
(An Information from Wikipedia)
Steps to Find Amicable Number are as follow :-
1. Read or initialize two numbers (N1, N2) from the user.
2. Find the divisor (divOfN1, divOfN2) of both numbers.
3. Find the sum of divisors (sumdiv1, sumdiv2) of both numbers.
4. Check if the sum of divisors of one number is equal to the other number or not.
Bille
March 19, 2018 at 1:47 pm ReplyExcellent
User_5067
Sep 04, 2018 at 9:50 am ReplyLmao !!
User_4056
November 09, 2019 at 11:03 pm ReplyNice