#include<stdio.h>
void main()
{
int n,i,sum=0;
clrscr();
printf("Enter a number: ");
scanf("%d",&n);
for(i=1;i<n;i++)
{
if(n%i==0)
sum=sum+i;
}
if(sum==n)
printf("%d is a perfect number",i);
else
printf("%d is not a perfect number",i);
getch();
}
void main()
{
int n,i,sum=0;
clrscr();
printf("Enter a number: ");
scanf("%d",&n);
for(i=1;i<n;i++)
{
if(n%i==0)
sum=sum+i;
}
if(sum==n)
printf("%d is a perfect number",i);
else
printf("%d is not a perfect number",i);
getch();
}
No comments:
Post a Comment