Pages

Sunday, 5 March 2017

Perfect Number


 Program to check perfect number

A number said to perfect if sum of all its divisor is equal to given number

i.e

Image from wikipedia

/*   ***********************************
           Girfa : Student Help
           Magic Number Program

           for more program visit :http://girfahelp.blogspot.in/p/number-programming-c-language.html
     ************************************/
#include<stdio.h>
void main()
{
     int n,m,s=0;
     printf("Enter Number>> ");
     scanf("%d",&n);
     for(m=1;m<n;m++)
     {
           if(n%m==0)
                s+=m;
     }
     if(s==n)
           printf("\n\t%d is Magic Number",n);
     else
           printf("\n\t%d is not a Magic number",n);

}

No comments:

Post a Comment