algoritmo "numeros_perfeitos"
var
c, n:inteiro
nv, np, npv:real
inicio
para n <- 1 ate 100 faca
para c <- 1 ate n faca
se n % c = 0 entao
nv <- n / c
se nv < n entao
np <- nv + np
fimse
fimse
fimpara
se np = n entao
escreva(np)
fimse
np <- 0
nv <- 0
fimpara
fimalgoritmo
I wrote this code for this exercise:
Write an algorithm that generates and writes the first 4 numbers perfect. A perfect number is one that is equal to the sum of your dividers. Ex: 6 = 1 + 2 + 3; 28 = 1 + 2 + 4 + 7 + 14.
But does it lock how much I put from n to 10,000 I did something wrong? And why does it run many cycles in the internal structure (think they are 100000 cycles)? My logic was bad?