Pages

Saturday, 15 September 2012

AMICABLE NUMBERS



/*Amicable Numbers*/


#include<stdio.h>
#include<conio.h>
void main()
{
int i,r=0,sum=0,sum1=0,a,b,temp,temp1;
printf("Enter first number\n");
scanf("%d",&a);
printf("Enter second number\n");
scanf("%d",&b);
temp=a;
for(i=1;i<=a/2;i++)
{
r=a%i;
if(r==0)
sum+=i;
}
temp=b;
for(i=1;i<=b/2;i++)
{
r=b%i;
if(r==0
sum1+=i;
}
if((sum==temp1)&&(sum==temp))
printf("amicable");
else
printf("not amicable");
getch();
}




No comments:

Post a Comment