p051.c¶
Problem Statement
Write a program to input two number and check whether they are Amicable Pair or not Example : Sum of Proper Divisors of 220 (1, 2, 4, 5, 10, 11, 20, 22, 44, 55, 110) = 284 Sum of Proper Divisors of 284 (1, 2, 4, 71, 142) = 220
Metadata¶
| Property | Detail |
|---|---|
| Author | Amit Dutta (amitdutta4255@gmail.com) |
| License | MIT |
Actions¶
💡 You can print or save this file by opening Raw and using your browser.
Source Code¶
#include <stdio.h>
int main()
{
int a, b, i, sa = 0, sb = 0;
printf("Enter two number : ");
scanf("%d %d", &a, &b);
for (i = 1; i <= a / 2; i++)
if (a % i == 0)
sa += i;
for (i = 1; i <= b / 2; i++)
if (b % i == 0)
sb += i;
if (sa == b && sb == a)
printf("\nInput %d and %d is Amicable Pair.", a, b);
else
printf("\nInput %d and %d is Not Amicable Pair.", a, b);
return 0;
}