nikolas_serafini

Lista 3 - Exercício 12

Jun 11th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2.      
  3. int main()
  4. {
  5.     int i,number,sum = 0;
  6.  
  7.     printf("Entre como numero :\n");
  8.     scanf("%d",&number);
  9.  
  10.     for (i = 1; i < number; i++)
  11.     {
  12.         if (number%i == 0)
  13.         {
  14.             sum = sum + i;
  15.         }
  16.     }
  17.    
  18.     if (sum == number)
  19.     {
  20.         printf("Numero perfeito!\n");
  21.     }
  22.     else
  23.     {
  24.         printf("O numero nao eh perfeito!\n");
  25.     }
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment