fork download
  1. program NumPerfeito;
  2. uses crt;
  3.  
  4. var cont, x, soma, i: integer;
  5.  
  6. begin
  7. clrscr;
  8. cont:=0;
  9. x:=0;
  10. writeln('Os numeros perfeitos sao: ');
  11.  
  12. repeat
  13. x:=x+1;
  14. soma:=0;
  15. for i:= 1 to x-1 do
  16. begin
  17. if x mod i = 0 then soma:=soma + i;
  18. end;
  19. if soma = x then
  20. begin
  21. writeln(x);
  22. cont:=cont+1;
  23. end
  24. until cont=4;
  25. writeln('Pressione qualquer tecla para finalizar...');
  26. readkey;
  27. end.
Success #stdin #stdout 0.59s 296KB
stdin
Standard input is empty
stdout
Os numeros perfeitos sao: 
6
28
496
8128
Pressione qualquer tecla para finalizar...