P051.c (919B)
1 /* Write a program to input two number and check whether they are Amicable Pair or not 2 Example : Sum of Proper Divisors of 220 (1, 2, 4, 5, 10, 11, 20, 22, 44, 55, 110) = 284 3 Sum of Proper Divisors of 284 (1, 2, 4, 71, 142) = 220 */ 4 5 // This code has not been compiled. 6 // If you find any issues, please create a new issue on GitHub regarding them. 7 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues 8 9 #include <stdio.h> 10 11 int main() 12 { 13 int a, b, i, sa = 0, sb = 0; 14 printf("Enter two number : "); 15 scanf("%d %d", &a, &b); 16 for (i = 1; i <= a / 2; i++) 17 if (a % i == 0) 18 sa += i; 19 for (i = 1; i <= b / 2; i++) 20 if (b % i == 0) 21 sb += i; 22 if (sa == b && sb == a) 23 printf("\nInput %d and %d is Amicable Pair.", a, b); 24 else 25 printf("\nInput %d and %d is Not Amicable Pair.", a, b); 26 return 0; 27 }