RosettaCodeData/Task/Perfect-numbers/Yabasic/perfect-numbers.basic

17 lines
424 B
Plaintext

sub isPerfect(n)
if (n < 2) or mod(n, 2) = 1 then return false : endif
// asumimos que los números impares no son perfectos
sum = 0
for i = 1 to n-1
if mod(n,i) = 0 then sum = sum + i : endif
next i
if sum = n then return true else return false : endif
end sub
print "Los primeros 5 numeros perfectos son:"
for i = 1 to 33550336
if isPerfect(i) then print i, " ", : endif
next i
print
end