fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. // your code goes here
  5. int n, i, sum=0;
  6. printf("Enter value of n:");
  7.  
  8. scanf("%d", &n);
  9. for(i=1;i<n;i++)
  10. {
  11. if(n%i==0)
  12. {
  13. sum=sum+i;
  14. }
  15. }
  16. if(n==sum)
  17. {
  18. printf("perfect no.");
  19. }
  20. else
  21. {
  22. printf("not");
  23. }
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
Enter value of n:perfect no.