Program :-
#include <sidio.h>
main(){
int num1,num2,i,j,sum1=0,sum2=0;
printf("enter two numbers :\n");
scanf("%d%d",&num1,&num2);
for(i = 1; i <= num1 / 2; i++)
{
if(num1 % i ==0)
sum1 = sum1 + i ;
}
for(j = 1; i <= num2 / 2; i++)
{
if(num2 % i ==0)
sum2 = sum2 + i ;
}
if(num1 == sum2 && num2 == sum1)
print("\n numbers are amicable");
else
print("\n numbers are not amicable");
}
Output :-
enter two numbers :
220
284
numbers are amicable
No comments:
Post a Comment