Wednesday, 3 October 2018

PERFECT Number Generation

#include<stdio.h>
#include<conio.h>
void main()
{int i,j,n,sum;
clrscr();
scanf("%d",&n);
for(i=1;i<=n;i++)
{       sum=0;
for(j=1;j<=i/2;j++)
{
if(i%j==0)
sum=sum+j;
}
if(sum==i)
printf("\n%d",sum);
}
getch();
}

No comments:

Post a Comment