function p = is_perfect(n) somma = 0; for i = 1:(n-1) if mod(n,i) == 0 somma = somma + i; end end if somma == n p = true; else p = false; end end