Program for Perfect Number


Program for Perfect Number
#include<stdio.h>
#include<conio.h>
main()
{
int n,n1,i,a,j=0;
clrscr();
printf("enter the value of n");
scanf("%d",&n);
n1=n;
for(i=1;i<n;i++)
{
a=n%i;

if(a==0)
j=j+i;
}
if(j==n1)
printf("the sum of factors of given number is perfect=%d",j);
else
printf("the sum of factors of given number is not perfect=%d",j);
getch();
}�

No comments:

Post a Comment