#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

main (int cant ,char *vec[])
{
  long cont=0;
  long a,b,suma,cotaInf;
  char *ptr;

  clrscr();
  puts("Numeros Perfectos : ");

  cotaInf = strtol(vec[1],&ptr,10);

  if (cotaInf==0)
     cotaInf=2;

  for (a=cotaInf;a<=2000000000;a++)
  {
    suma=0;
    gotoxy(70,1);
    printf("%lu",a);
    for (b=1;b<=(a/2);b++)
    {
      if (a % b == 0)
	suma+=b;
      if (suma>a)
	goto FUERACICLO;
    }
    FUERACICLO:
    if (suma==a)
    {
      cont++;
      gotoxy(1,cont+3);
      printf("  %luĝ ==>  %lu\n",cont,a);
      sound(200);
      delay(1000);
      nosound();
    }
    gotoxy(70,1);
    printf("           ");
  }
  gotoxy(1,20);
  getch();
  return(0);
}