RenHao

e-Tutor_2

Sep 20th, 2015
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define MAX_VALUE 10000
  4. int main(int argc, const char * argv[])
  5. {
  6.     int j = 0,i_nums=0,FactorSum=0;
  7.     char c_nums[MAX_VALUE];
  8.     while(1)
  9.     {
  10.         scanf("%s",c_nums);
  11.         i_nums = atoi(c_nums);
  12.         if(i_nums != 0)
  13.         {
  14.             FactorSum = 0;
  15.             if(i_nums == 1) printf("%d No\n",i_nums);
  16.             else
  17.             {
  18.                 for(j = 1; j<i_nums/2+1; j++)
  19.                 {
  20.                     if(i_nums % j == 0)  FactorSum = FactorSum + j;
  21.                     else    ;
  22.                 }
  23.                 if(FactorSum == i_nums)  printf("%d Yes\n",i_nums);
  24.                 else    printf("%d No\n",i_nums);
  25.             }
  26.         }
  27.         else    return 0;
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment