Advertisement
mustahidhasan

perfect number

Feb 24th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main(){
  4.  
  5.  
  6.     int i, n, summation = 0;
  7.     scanf("%d", &n);
  8.     for(i = 1; i < n; i++){
  9.         if(n % i == 0){
  10.             summation = summation + i;
  11.         }
  12.     }
  13.     if(summation == n){
  14.         printf("number is perfect\n");
  15.     }else{
  16.         printf("the number is not perfect\n");
  17.     }
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement