Skip to content

Instantly share code, notes, and snippets.

@ahoulgrave
Created May 22, 2013 19:12
Show Gist options
  • Save ahoulgrave/5630104 to your computer and use it in GitHub Desktop.
Save ahoulgrave/5630104 to your computer and use it in GitHub Desktop.
Algoritmo para saber si un número es perfecto
ALGORITMO numeroPerfecto
var
int:
i, num, res, sumaDivisores
Inicio
i = 1
res = 0
sumaDivisores = 0
LEER num
MIENTRAS i <= num-1 ENTONCES
res = num MOD i
SI res == 0 ENTONCES
sumaDivisores = sumaDivisores+i
FIN_SI
i = i+1
FIN_MIENTRAS
SI sumaDivisores == num ENTONCES
ESCRIBIR "El número es perfecto"
SINO
ESCRIBIR "El número no es perfecto"
FIN_SI
Fin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment