Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int n, i, j, sum=0;
clrscr();
printf("Enter any Number :");
scanf("%d", &n);
printf("Perfect Number Between 1 to %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("\t%d", i);
}
getch();
}
No comments:
Post a Comment