Piprimes: Difference between revisions

Piprimes en BASIC256 y Yabasic
(Added 11l)
(Piprimes en BASIC256 y Yabasic)
Line 166:
 
=={{header|BASIC}}==
==={{header|BASIC256}}===
{{trans|FreeBASIC}}
<lang BASIC256>function isPrime(v)
if v < 2 then return False
if v mod 2 = 0 then return v = 2
if v mod 3 = 0 then return v = 3
d = 5
while d * d <= v
if v mod d = 0 then return False else d += 2
end while
return True
end function
 
running = 0 : curr = 0 : limite = 22
while True
curr += 1
if isPrime(curr) then running += 1
if running = limite then exit while
print running; " ";
end while
end</lang>
{{out}}
<pre>
Igual que la entrada de FreeBASIC.
</pre>
 
==={{header|FreeBASIC}}===
Line 200 ⟶ 225:
IF I*I <= P THEN GOTO 110
RETURN</lang>
 
==={{header|Yabasic}}===
{{trans|FreeBASIC}}
<lang yabasic>sub isPrime(v)
if v < 2 then return False : fi
if mod(v, 2) = 0 then return v = 2 : fi
if mod(v, 3) = 0 then return v = 3 : fi
d = 5
while d * d <= v
if mod(v, d) = 0 then return False else d = d + 2 : fi
wend
return True
end sub
 
running = 0 : curr = 0 : limite = 22
do
curr = curr + 1
if isPrime(curr) then running = running + 1 : fi
if running = limite break
print running using "##", " ";
loop
end</lang>
{{out}}
<pre>
Igual que la entrada de FreeBASIC.
</pre>
 
 
=={{header|C}}==
2,148

edits