Perfect number : is a positive integers which is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors excluding the number itself
(or)
Perfect number : is a positive integers which is equal to the sum of its proper positive factors, that is, the sum of its positive factors excluding the number itself
For example
#include<stdio.h> int main() { int n,sum=0; printf("Enter a number: "); scanf("%d",&n); for(int i=1;i<n;i++) { if(n%i==0) sum+=i; } if(n==sum) printf("\n %d is a Perfect number",n); else printf("\n %d is not Perfect number",n);return 0;
}


No comments:
Post a Comment