Perfect numbers: Difference between revisions
Content added Content deleted
(Perfect numbers en BASIC256) |
(Perfect numbers en Yabasic) |
||
Line 3,851: | Line 3,851: | ||
33550336 |
33550336 |
||
</pre> |
</pre> |
||
=={{header|Yabasic}}== |
|||
{{trans|True BASIC}} |
|||
<lang basic> |
|||
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 |
|||
</lang> |
|||
=={{header|Zig}}== |
=={{header|Zig}}== |