Advertisement
Schknheit

Numero perfeito

Apr 10th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.  
  5. int num, cont, soma = 0;
  6.  
  7. printf("Entre com um inteiro positivo\n");
  8. scanf("%d",&num);
  9. for(cont = 1;cont < num; cont++){
  10.  
  11. if(num % cont == 0){
  12.  
  13. soma = soma + cont;
  14. }
  15.  
  16. }
  17. if(soma==num){
  18.  
  19. printf("E perfeito\n");
  20. }
  21.  
  22. else{
  23. printf("Nao e perfeito\n");
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement