Amicable numbers

Q. writes a C program to check whether given two numbers are amicable numbers or not.


Definition of Amicable numbers: Amicable numbers are two numbers so related that the sum of the proper divisors of the one is equal to the other, unity being considered as a proper divisor but not the number itself.

For example, lets a pair or two number pair is (220,284),
For the proper divisor of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55, 110, of which the sum is 284.
And the proper divisor of 284 are 1, 2, 4, 71, 142 of which the sum is 220.

/*program to check whether given numbers are amicable or not*/
int main()
 int n1,n2,s1=0,s2=0,i;
 printf("Enter first number : ");
 printf("Enter second number : ");
 for(i=1; i<n1 ; i++)
 for(i=1; i<n2 ; i++)
 if(n1==s2 && n2==s1)
  printf("Given numbers are Amicable Numbers");
  printf("Given numbers are Not Amicable Numbers");
 return 0;


Enter first number : 452
Enter second number : 264
Given numbers are Not Amicable Numbers

Enter first number : 220
Enter second number : 284
Given numbers are Amicable Numbers

Related Programs:
  1. Search Perfect number C program
  2. Search Armstrong number C program
  3. Print Armstrong number range C program
  4. Flowchart for check a number is Armstrong or not

No comments:

Post a Comment