PERFECT NUMBERS RANGE IN BETWEEN MIN AND MAX :
// program to illustrate min and max range of perfect number
#include<stdio.h> // header section
#define pf printf // define section
#define sf scanf // define section
void main()
{
int sum,min,max,n,i,temp;
pf("\nEnter min number:");
sf("%d",&min);
pf("\nEnter max number:");
sf("%d",&max);
pf("\n Perfect number are :");
for(n=min;n<=max;n++)
{
i=1,sum=0;
while(i < n)
{
if( n % i == 0 )
sum=sum + i;
i++;
}
if(sum == n)
pf("\n%d",n);
}
}
output:
No comments:
Post a Comment